Compiling C++ code

Tagged: 

This topic contains 8 replies, has 3 voices, and was last updated by  alastair 3 years, 6 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #31639

    denisrono
    Member

    Is there a tool in the MetaFlow SDK that allows one to compile C++ code for the minimorph?

    1 user thanked author for this post.
    #38502

    Sean
    Moderator

    Yes, but it’s not enabled by default.

    cd GPL/buildroot
    make menuconfig

    Enable it under “Toolchain” -> “Toolchain has C++ support?”

    Rebuild buildroot and it should be available.

    Regards,

    Sean.

    1 user thanked author for this post.
    #38503

    denisrono
    Member

    Thanks I will give it a go

    #38504

    denisrono
    Member

    I assume one then compiles the C++ code by entering the following into a makefile:

    test: test.cpp
    $(CROSS_COMPILE)cpp $(TARGET_LDFLAGS) -g -o $@ $^

    5 users thanked author for this post.
    #38505

    denisrono
    Member

    Hey,

    when I use the syntax above in a Makefile and try to compile a simple “hello,world” application, I get the following error:
    /home/kipchirchir/Meta-Linux-SDK/GPL/buildroot/output/host/usr/bin/metag-linux-cpp -g -o test test.cpp
    metag-linux-cpp: test.cpp: C++ compiler not installed on this system
    make: *** [test] Error 1
    I have both g++ and build-essential installed on my machine. Is there anything further I need to do to compile the C++ code or did I not follow your previous instructions properly?

    Thanks

    #38506

    alastair
    Moderator

    Are you trying to compile on the Minimorph itself or on your host machine?
    Have you set up your CROSS_COMPILE environment variable?

    #38507

    alastair
    Moderator

    On investigation, it looks like you are calling the wrong file from your makefile.
    Check in your buildroot/output/host/usr/bin/ directory for a file called metag-linux-g++

    If that is there, then you’ve managed to rebuild buildroot with C++ support.

    Then in the your makefile, replace the cpp with g++ as below

    test: test.cpp
    $(CROSS_COMPILE)g++ $(TARGET_LDFLAGS) -g -o $@ $^

    2 users thanked author for this post.
    #38508

    denisrono
    Member

    Hi,

    I properly rebuilt the buildroot directory by first calling:make cleanthenmakeThe C++ code compiled successfully, however, when i try to run the code on the minimorph, I get the following error:./testcpp: can't load library 'libstdc++.so.6'I have tried reflashing the board but the error still persists. Would I need to rebuild the linux kernel and adding certain modules?

    Thanks

    4 users thanked author for this post.
    #38509

    alastair
    Moderator

    You could try linking statically to to libstdc++.so by recompiling your app with the -static-libstdc++ gcc option.

    1 user thanked author for this post.
Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic.