STLport for eCos

eCos does not come with a C++ STL implementation, yet.

http://www.ecoscentric.com has recently ported libstdc++ to eCos.

However, after www.stlport.com committed a few patches and made some key improvements, only a few tweaks are required to get STLport to work with eCos.

Prerequisites skills

  • Before you attempt this, you should have your first eCos application up and running.
  • Basic CVS skills(e.g. how to check out and how to apply patches).

Fetch and patch STLport

From CygWin/Linux command prompt:
  • cd /stlhome
  • cvs -d :pserver:cvs@cvs.stlport.com:/stlport checkout -D "2004/04/13 13:00:00" STLport
  • cd STLport
  • patch -p0 <ecosstlpatch.txt
Where "/stlhome" is where you have decided to keep STLport.

Compile STLport

From CygWin/Linux command prompt:
  • cd /stlhome/STLport/stlport/src
  • make -f gcc-ecos.mak INSTALL_DIR=/myecosapp/install ECOSTOOLS=/ecos-installdir/ecos/gnutools/arm-elf/arm-elf/include/arm-elf install
Where:
  • "arm-elf" is the prefix to your toolchain.
  • "/myecosapp/" is the directory where you configured and compiled eCos for you application
  • "/ecos-installdir/" is the location where you installed eCos.

Compiling and linking your application code with STLport

Below you you will find a matching makefile and hello.cpp. No doubt you have your own makefile, application and toolchain already set up, so pick the pieces you need and want.

To compile and link the hello world app.

  • cd /stltest
  • ecosconfig new eb40a default
  • ecosconfig add fileio
  • For EB40a, you'll need to change startup type CYG_HAL_STARTUP="ROM". STL is expensive in code size but not terrible in RAM usage.
  • make
  • cd /stlhello
  • cp hello.cpp .
  • cp makefile .
  • make INSTALL_DIR=/myecosapp/install STLPORT=/stlhome/STLport
Voila! At this point you should have a linked executable.

Where:

  • "/stlhome" is where you have decided to keep STLport.
  • "/myecosapp/" is the directory where you configured and compiled eCos for you application

Mini FAQ

  • Q: STLport doesn't compile!

    A:STLport requires quite a few underlying OS services such as malloc, fileio, etc. If you are seing compile/link errors, you may be missing one of the required pieces. I believe the right way of fixing this problem is to add a "ecosconfig add stlport".

  • Q: STLport doesn't compile!

    A: It was tested with the prebuilt tool chains from eCos.

  • Q: STLport streams are slow!

    A: You may be running into this problem: http://sources.redhat.com/ml/ecos-patches/2004-02/msg00072.html

  • Q: I need multithreaded exceptions support!

    A: You may need multithreaded C++ exceptions. Always a bit hairy in eCos. If using pthreads is not an option, perhaps the alternative approach below could do the trick? http://sources.redhat.com/ml/ecos-patches/2003-11/msg00047.html

  • Q: The example above with eb40a does not compile!

    A: A lot of work has been committed to the CVS since eCos 2.0. Fetch the latest:

    http://ecos.sourceware.org/anoncvs.html

  • Q: Why haven't the STLport guys committed this yet?

    A: They've got plenty of stuff to keep them busy and they have committed parts of the patch. It just takes time.