Compiling C++ code

Home Forums MIPS Insider Meta Insider Compiling C++ code

This topic contains 8 replies, has 3 voices, and was last updated by  Sean 4 years, 7 months ago.

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

    denisrono
    Participant

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

    #64652

    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.

    #64651

    denisrono
    Participant

    Thanks I will give it a go

    #64650

    denisrono
    Participant

    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 $@ $^

    #64649

    denisrono
    Participant

    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

    #64648

    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?

    #64647

    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 $@ $^

    #64646

    denisrono
    Participant

    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

    #64645

    alastair
    Moderator

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

Viewing 9 posts - 1 through 9 (of 9 total)

Forums are currently locked.