C++ for embedded systems

angelo angelo at hunterlink.net.au
Wed Oct 11 00:49:41 UTC 2000


I seem to be having the problem also that I am not linking with the standard
C++ libraries also.

for the following file, I get the link error following.  What must be done to
solve this?

#include <iostream>
#include <fstream>

int x ()
{
  ifstream testfile ("testfile");
  if (testfile)
    {
      cout <<"testfile opened"<<endl;
      testfile.close();
    }
  else
  {
    cout<<"unable to open file"<<endl;
  }

  return 1;
}

*************************************************************
Error message
*************************************************************

/opt/rtems/bin/i386-rtems-gcc --pipe -B/opt/rtems//pc386/lib/ -specs bsp_specs
-
qrtems -g -Wall -ansi -fasm  -O4           -L /opt/rtems//pc386/lib
-Wl,-Ttex
t,0x00100000 -o o-optimize/smart.obj   o-optimize/mainline.o
o-optimize/testcpp.
o  /opt/rtems//pc386/lib/no-dpmem.rel /opt/rtems//pc386/lib/no-event.rel
/opt/rt
ems//pc386/lib/no-msg.rel /opt/rtems//pc386/lib/no-mp.rel
/opt/rtems//pc386/lib/
no-part.rel /opt/rtems//pc386/lib/no-signal.rel
/opt/rtems//pc386/lib/no-timer.r
el /opt/rtems//pc386/lib/no-rtmon.rel
o-optimize/testcpp.o: In function `x(void)':
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:6: undefined reference
to
 `ifstream::ifstream(int, char const *, int, int)'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:7: undefined reference
to
 `ios::operator void *(void) const'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:9: undefined reference
to
 `endl(ostream &)'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:9: undefined reference
to
 `cout'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:9: undefined reference
to
 `ostream::operator<<(char const *)'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:9: undefined reference
to
 `ostream::operator<<(ostream &(*)(ostream &))'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:10: undefined reference
t
o `fstreambase::close(void)'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:14: undefined reference
t
o `endl(ostream &)'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:14: undefined reference
t
o `cout'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:14: undefined reference
t
o `ostream::operator<<(char const *)'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:14: undefined reference
t
o `ostream::operator<<(ostream &(*)(ostream &))'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:17: undefined reference
t
o `ifstream::~ifstream(void)'
/home/angelo/SmartControl/source/hal_rtems/testcpp.cpp:17: undefined reference
t
o `ifstream::~ifstream(void)'
collect2: ld returned 1 exit status
make: *** [o-optimize/smart.exe] Error 1


Nick.SIMON at syntegra.bt.co.uk wrote:

> Are you really sure you want objects in ROM?  They wouldn't be very
> dynamic!
>
> We have lots of C++ code running under RTEMS.  Objects, whether globals or
> dynamically created, live in RAM.  Snags are:
>
> (1)  Performance is hit somewhat by the code inserted by the compiler for
> exception handling.  I haven't found a way to disable this in the compiler,
> else we'd do without EH for performance's sake.
> (2)  Link has to be just right (in file linkcmds in the BSP) if you want
> global constructors to work.
>
> Best wishes
>
> -- Nick Simon
>
> > -----Original Message-----
> > From: Peter Mueller [mailto:peter.o.mueller at gmx.de]
> > Sent: 08 October 2000 19:18
> > To: rtems-users at oarcorp.com
> > Subject: C++ for embedded systems
> >
> >
> > Hi all,
> >
> > I want to use C++ for a project with rtems. No problems so
> > far. But I'm
> > very unsure how to write C++ code that "is good" for embedded systems.
> > Especially how can I make sure an object can be in ROM ...
> >
> > Is there a good tutorial ... about points to consider when
> > developing C++
> > code for embedded systems. I know the EC++ stuff a bit, but
> > there is no info
> > about my memory related questions there.
> >
> > Thanks,
> > Peter
> >
> > --
> > Sent through GMX FreeMail - http://www.gmx.net
> >

--
Angelo Fraietta

PO Box 859
Hamilton NSW 2303

Home Page

http://users.hunterlink.net.au/~maaaf/

There are those who seek knowledge for the sake of knowledge - that is
CURIOSITY
There are those who seek knowledge to be known by others - that is VANITY
There are those who seek knowledge in order to serve - that is LOVE
    Bernard of Clairvaux (1090 - 1153)






More information about the users mailing list