How to I get crosstool-ng C++ compiler working

Jim picture Jim · Oct 18, 2012 · Viewed 9.6k times · Source

I'm trying to get crosstool-ng working with both C and C++. Even though I've selected C++ while using menuconfig, it doesn't seem to get built. The gcc compiler works as expected but not g++

I'm not sure what I'm doing wrong so any help would be appreciated.

I followed the steps found here: Building embedded ARM systems with Crosstool-NG

$ arm-unknown-linux-gnueabi-cpp main.cpp -o test
arm-unknown-linux-gnueabi-cpp: main.cpp: C++ compiler not installed on this system

NOTE: there is no arm-unknown-linux-gnueabi-g++ found on in the bin directory. I've tried cross-tool version 1.16.0 and 1.15.3

arm-unknown-linux-gnueabi-cpp -v
Using built-in specs.
Target: arm-unknown-linux-gnueabi
Configured with: /opt/crossArm/.build/src/gcc-4.3.2/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-unknown-linux-gnueabi --prefix=/opt/crossArm/.build/arm-unknown-linux-gnueabi/buildtools --with-local-prefix=/home/jgarvin/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot --disable-libmudflap --with-sysroot=/home/jgarvin/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot --enable-shared --with-pkgversion='crosstool-NG 1.16.0' --with-float=soft --enable-__cxa_atexit --with-gmp=/opt/crossArm/.build/arm-unknown-linux-gnueabi/buildtools --with-mpfr=/opt/crossArm/.build/arm-unknown-linux-gnueabi/buildtools --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-nls --disable-multilib --enable-languages=c
Thread model: posix
gcc version 4.3.2 (crosstool-NG 1.16.0)

Code

#include<iostream>

using namespace std;

int main(){
   cout<<"Hello World"<<endl;
return 0;
}

In my build.log file I see C++ option turned on

[DEBUG]    CT_CC_SUPPORT_CXX=y

I also see it in the config.log:

configure:3030: $? = 0
configure:3019: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu

Answer

artless noise picture artless noise · Jan 21, 2013

From, http://briolidz.wordpress.com/2012/02/07/building-embedded-arm-systems-with-crosstool-ng/

Refine your configuration by running the menuconfig interface:

$ ./ct-ng menuconfig

In this step, navigate to the C Compiler menu. Then you can select C++ or de-select Java, Fortran, etc. Since crosstool-ng is just a bunch of scripts and patch files, it is very rare that a development build breaks things. You can always pull from the hg repository.

hg clone http://crosstool-ng.org/hg/crosstool-ng
cd crosstool-ng
./bootstrap
make
sudo make install

This will have the latest fixes. I have built arm cross compilers with C++ support many times using this method [including Canadian crosses for Mingw and i386 from an x86_64 host].

EDIT: I see that the wordpress link recommends a local install of ct-ng. The commands above do a full install, putting things in /usr/local. Also, it seems the OP did try to set menuconfig's C++ option. Try altering the sjlj value, use the latest version of ct-ng and install it. This produces an ARM Linux C++ cross-compiler on Ubuntu for me. The build.log output can be helpful in determining if ct-ng decided some configuration was impossible.

Finally, the mailing list [email protected] doesn't require subscription afaik. The archives at http://sourceware.org/ml/crossgcc/ can be helpful. If you still have issues, I am sure someone on the mailing list will be able to help you.

EDIT: With the latest ct-ng installed try,

$ ct-ng arm-cortex_a15-linux-gnueabi #Alternate arm-yem-linux-gnueabi
$ ct-ng menuconfig # Tweak for your processor, gcc version, etc.
$ ct-ng build # Go have a coffee (or work on something else).

Sorry, your host compiler was made with Linaro. I was reading too much into your edit.