Announcement

Collapse
No announcement yet.

Building C++/STLPort apps

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Building C++/STLPort apps

    Short version: has anyone succeeded in building C++ and/or STLport apps in the SDK (2.0.0.3)?

    I'm trying to add in the 'mrd6' package, which is c++. I'm not now totally sure if it does need the STLport library, but that was the first route I followed. (Though its a couple of days later and I don't really remember why.. :S)

    However STLport is also giving problems: I've tried to build the helloworld example in the 'cxxtests' package; I've tried to build nmap [which hits the same failure as another thread reports]; I've tried asterisk, but this wants a shared STLport so yet another diversion.

    I'm kinda losing my way on what is the best way to track down what my makefile needs - think I'm basically looking for anything c++ I can get building successfully, just to have a known good reference point to move on from. But anything I try that I think might work out-of-the-box just throws up other distracting issues to tackle.

    Has anyone had any c++ success...?
    Thanks

  • #2
    I've managed to get the cxxtest apps running with STLport.
    SDK 2.0.0.3 patched as follows:

    diff -aur default_xportpro-linux-sdk/linux/lib/STLport/build/Makefiles/gmake/gcc.mak cxx_xportpro-linux-sdk/linux/lib/STLport/build/Makefiles/gmake/gcc.mak
    --- default_xportpro-linux-sdk/linux/lib/STLport/build/Makefiles/gmake/gcc.mak 2006-01-16 01:56:07.000000000 +0000
    +++ cxx_xportpro-linux-sdk/linux/lib/STLport/build/Makefiles/gmake/gcc.mak 2013-02-02 17:10:45.692996323 +0000
    @@ -21,11 +21,11 @@
    CXX_VERSION_PATCH := $(shell ${CXX} -dumpversion | awk 'BEGIN { FS = "."; } { print $3; }')
    else
    ifneq ($(OSNAME), windows)
    -CXX_VERSION := $(shell ${CXX} --version | grep GCC | awk '{ print $$3; }')
    +CXX_VERSION := $(shell ${CXX} -dumpversion | grep GCC | awk '{ print $$3; }')

    ifeq ($(CXX_VERSION),)
    # 2.95 report only version
    -CXX_VERSION := $(shell ${CXX} --version)
    +CXX_VERSION := $(shell ${CXX} -dumpversion)
    endif

    CXX_VERSION_MAJOR := $(shell echo ${CXX_VERSION} | awk 'BEGIN { FS = "."; } { print $$1; }')
    diff -aur default_xportpro-linux-sdk/linux/lib/STLport/Makefile cxx_xportpro-linux-sdk/linux/lib/STLport/Makefile
    --- default_xportpro-linux-sdk/linux/lib/STLport/Makefile 2011-12-20 09:10:05.000000000 +0000
    +++ cxx_xportpro-linux-sdk/linux/lib/STLport/Makefile 2013-02-03 13:15:05.932999367 +0000
    @@ -17,6 +17,7 @@
    endif
    OPT += -I$(TOP_DIR)/include/STLport
    OPT += -D_STLP_NATIVE_INCLUDE_PATH=../c++
    + OPT += -fPIC
    endif

    all:
    diff -aur default_xportpro-linux-sdk/linux/user/cxxtest/helloworld/helloworld.cxx cxx_xportpro-linux-sdk/linux/user/cxxtest/helloworld/helloworld.cxx
    --- default_xportpro-linux-sdk/linux/user/cxxtest/helloworld/helloworld.cxx 2004-04-07 01:18:42.000000000 +0100
    +++ cxx_xportpro-linux-sdk/linux/user/cxxtest/helloworld/helloworld.cxx 2013-02-03 15:02:08.256999924 +0000
    @@ -1,4 +1,5 @@
    #include <iostream>
    +#include <unistd.h>

    int main(int argc, char *argv[])
    {
    diff -aur default_xportpro-linux-sdk/linux/user/cxxtest/helloworld/Makefile cxx_xportpro-linux-sdk/linux/user/cxxtest/helloworld/Makefile
    --- default_xportpro-linux-sdk/linux/user/cxxtest/helloworld/Makefile 2006-06-07 07:58:16.000000000 +0100
    +++ cxx_xportpro-linux-sdk/linux/user/cxxtest/helloworld/Makefile 2013-02-03 15:19:36.329000531 +0000
    @@ -3,13 +3,11 @@
    CCOBJS1=helloworld.o
    CCSRC1=helloworld.cxx

    -CXXFLAGS += -I$(STL_INCDIR)
    -CXX_LDFLAGS += -L$(STL_LIBDIR)

    all: $(EXE1)

    $(EXE1): $(CCOBJS1)
    - $(CXX) $(CXX_LDFLAGS) -o $@ $(CCOBJS1) $(LIBM) $(CXXLIBS)
    + $(CXX) $(CXX_LDFLAGS) -o $@ $(CCOBJS1) $(LIBM) $(CXXLIBS)

    $(CCOBJS1): $(CCSRC1)
    $(CXX) -c $(CXXFLAGS) -o $@ $(CCSRC1)
    diff -aur default_xportpro-linux-sdk/linux/user/cxxtest/iostream/iostream.cxx cxx_xportpro-linux-sdk/linux/user/cxxtest/iostream/iostream.cxx
    --- default_xportpro-linux-sdk/linux/user/cxxtest/iostream/iostream.cxx 2006-06-07 07:58:16.000000000 +0100
    +++ cxx_xportpro-linux-sdk/linux/user/cxxtest/iostream/iostream.cxx 2013-02-03 15:07:43.860999940 +0000
    @@ -4,7 +4,8 @@
    #include <fstream>
    #include <sstream>

    -#define TEST_FILE "/etc/config/smgrd.xml"
    +//#define TEST_FILE "/etc/config/smgrd.xml"
    +#define TEST_FILE "/etc/inittab"

    int main(int argc, char *argv[])
    {
    diff -aur default_xportpro-linux-sdk/linux/user/cxxtest/Makefile cxx_xportpro-linux-sdk/linux/user/cxxtest/Makefile
    --- default_xportpro-linux-sdk/linux/user/cxxtest/Makefile 2007-03-13 00:55:46.000000000 +0000
    +++ cxx_xportpro-linux-sdk/linux/user/cxxtest/Makefile 2013-02-03 15:19:58.905000100 +0000
    @@ -1,5 +1,23 @@
    -SUBDIRS=sharedlib helloworld constructor exceptions iostream
    +SUBDIRS=helloworld constructor exceptions iostream
    +# Skip the sharedlib, we don't have them
    +#SUBDIRS=sharedlib helloworld constructor exceptions iostream

    +# Modify the compiler options
    +CXXFLAGS += -I$(ROOTDIR)/lib/STLport/../../include/c++/m68k-uclinux/msep-data
    +CXXFLAGS += -D_STLP_NATIVE_INCLUDE_PATH=../c++
    +CXXFLAGS += -fPIC
    +CXXFLAGS += -fexceptions
    +
    +# Create and export the linker and library options
    +# These are actually copied from the compiler flags, but seem to work. Using LDFLAGS
    +# doesn't though
    +CXX_LDFLAGS += -fomit-frame-pointer -pipe -fno-common -fno-builtin -fno-dwarf2-cfi-asm -msep-data -D__linux__ -Dunix -D__uClinux__ -DEMBED -Os -g
    +CXX_LDFLAGS += -static
    +
    +CXXLIBS = -lstdc++ -lsupc++
    +
    +export CXX_LDFLAGS
    +export CXXLIBS

    all:
    %:

    I'm not saying this is perfect and/or optimum, but at least the apps build and run.

    / # ./cxx_constructor
    Static Global Class Value = 666
    Nonstatic Global Class Value = 666
    Static Class Value = 666
    Nonstatic Class Value = 666
    foobar
    / # ./cxx_except
    Entering the exception program
    Exception thrown
    Handling Exception
    / # ./cxx_exception
    program starting
    copy called
    Caught MyException exception:
    / # ./cxx_helloworld
    Hello, world
    / # ./cxx_iostream
    / #
    Not sure yet if these results are correct, but as I say, at least they run...!

    Comment


    • #3
      On closer inspection, the iostream test seems to be failing - also seems to be borne out by trying my own app.
      A file can be opened ok, but then the app bombs out on the ifstream::read.
      Not sure whether to try porting a later version of STLport into the SDK....

      Comment


      • #4
        Interestingly, if not yet helpfully, I've found I can also compile the cxxtest apps with just "m68k-uclinux-g++ <source>.cxx"
        These give the following output:
        / # ./constructor_n
        Static Global Class Value = 666
        Nonstatic Global Class Value = 666
        Static Class Value = 666
        Nonstatic Class Value = 666
        foobar
        / # ./except_n
        Entering the exception program
        Exception thrown
        Handling Exception
        / # ./exception_n
        program starting
        copy called
        Caught MyException exception:
        / # ./helloworld_n
        Hello, world
        / # ./iostream_n
        --::sysinit:/etc/init.d/rcS
        ::restart:/sbin/init
        ::ctrlaltdel:/sbin/reboot
        ::shutdown:/bin/umount -a -r
        #ttyS0::askfirst:-/bin/sh
        --
        Read to file successfully
        i.e. the iostream app works correctly

        Comment

        Working...
        X