GCC 4.9.2 cross-compiler build for ARM - c++

I am trying to build a cross-compiler for ARM. When I add c++ to my "enable-languages" list in the configure (see) below, the gmake errors out with:
checking for exception model to use...
configure: error: unable to detect exception model
gmake[1]: *** [configure-target-libstdc++-v3]
but when I take c++ out of the "enable-languages", as in my configure script below, the GCC cross-compiler builds just fine.
../gcc-4.9.2/configure --prefix=/home/me/ANDROID21 --target=arm-linux-androideabi
--with-gmp=/home/me/ANDROID21 --with-mpfr=/home/me/ANDROID21
--with-mpc=/home/me/ANDROID21
--with-gnu-as--with-gnu-ld --enable-languages=c,fortran --disable-nls
--disable-tls
--disable-bootstrap --disable-libgomp --disable-shared --disable-libssp
-disable-libquadmath --enable-threads --enable-target-optspace --disable-libatomic
--with-sysroot=/home/me/android-ndk-r10c/platforms/android-21/arch-arm
For reference, here is my machine info:
$ uname -a
Linux (system name) 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
And the GCC I'm building off of:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/me/GCC4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/me/gcc-4.9.2/configure --prefix=/home/me/GCC4.9.2 --disable-multilib
--enable-libgomp --enable-languages=c,c++,objc,obj-c++,java,fortran
Thread model: posix
gcc version 4.9.2 (GCC)
Any ideas on possible causes?
Haven't found anything definitive in the archives yet. Would really like to get the c++ portion to cross-compile too.
TIA,
Steve

Related

Why do `gcc -v` and `whereis gcc` output different paths?

I get the following output when I run respectively gcc -v and whereis gcc:
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Target: x86_64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
gcc: /usr/bin/gcc
Does this mean I have multiple installations of gcc on my mac ? If so, how do I uninstall the 'extra/unnecessary' ones ?
Thanks

Homebrew gcc can't find omp.h on OS X

I've spent hours trying different solutions but nothing has worked so far.
I've installed gcc via Homebrew, and linked gcc to the Homebrew gcc. gcc -v returns this:
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/5.3.0/libexec/gcc/x86_64-apple-darwin14.5.0/5.3.0/lto-wrapper
Target: x86_64-apple-darwin14.5.0
Configured with: ../configure --build=x86_64-apple-darwin14.5.0 --prefix=/usr/local/Cellar/gcc/5.3.0 --libdir=/usr/local/Cellar/gcc/5.3.0/lib/gcc/5 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew gcc 5.3.0 --without-multilib' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 5.3.0 (Homebrew gcc 5.3.0 --without-multilib)
However, when I try to compile I get
This is make_MWA_Tools.sh
using $CFITSIO =
building LFILE & read_mwac utilities
cc -g -O -Wall -D_FILE_OFFSET_BITS=64 -fopenmp -c mwac_utils.c
mwac_utils.c:3:10: fatal error: 'omp.h' file not found
#include <omp.h>
^
1 error generated.
make: *** [mwac_utils.o] Error 1
!!!!!!!!!!!!!!!!!!!!!!
build_lfiles/read_mwac make failed !
I've looked in gcc located under Cellar and found mop.h, but for some reason its not being included. Any help would be greatly appreciated.
Edit: I don't believe this is a duplicate question because I could not find another question that Installed gcc from Homebrew, linked 'gcc' to the homebrew gcc installation, and still couldn't find omp.h

C++11: Compile and Execute: cross-platform compilation

I have a short C++ code that I have successfully compiled on a remote server A. I wish to run the executable on another target remote server T.
The code main.cpp contains the following snippet (requires C++11 support):
#include <random>
default_random_engine GENERATOR;
void get_random_indices(set<int> &output, int max_ind) {
uniform_int_distribution<int> dist(0, max_ind);
while (output.size() < SAMPLE_SIZE) {
output.insert(dist(GENERATOR));
}
}
I compiled the code using the following line:
g++ -o exec_foo -std=c++11 main.cpp
The spec of server A is
[me#A ~]$ uname -a
Linux some-ip:D 2.6.32-573.1.1.el6.x86_64 #1 SMP Tue Jul 14 02:46:51 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
[me#A ~]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/nfs/nfs5-insecure/home/insecure-ro/software/rhel6_x86_64/gcc-5.1.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/l/gcc-5.1.0
Thread model: posix
gcc version 5.1.0 (GCC)
When I run the exec_foo in server A, it works fine. Now running the same executable on the target server T results in the following error:
./exec_foo: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by ./exec_foo)
./exec_foo: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by ./exec_foo)
./exec_foo: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./exec_foo)
Checking the spec on target server T, I see the following:
-bash-4.1$ uname -a
Linux marry-christmas 2.6.32-358.6.2.el6.marry-christmas.20130516.x86_64 #1 SMP Fri May 17 04:49:39 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
-bash-4.1$ g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
OK, I get it. Server T can't find some links of library. But I can't compile the code natively on T:
-bash-4.1$ g++ -o exec_foo --std=c++11 main.cpp
cc1plus: error: unrecognized command line option "-std=c++11"
No c++11. Let's try c++0x.
-bash-4.1$ g++ -o exec_foo --std=c++0x main.cpp
main.cpp:64: error: ‘default_random_engine’ does not name a type
main.cpp: In function ‘void get_random_indices(std::set<int, std::less<int>, std::allocator<int> >&, int)’:
main.cpp:66: error: ‘uniform_int_distribution’ was not declared in this scope
main.cpp:66: error: expected primary-expression before ‘int’
main.cpp:66: error: expected ‘;’ before ‘int’
main.cpp:69: error: ‘GENERATOR’ was not declared in this scope
main.cpp:69: error: ‘dist’ was not declared in this scope
Besides updating the bloody g++ + gcc on server T, which I don't have rights to do, is there a way out?

Linking libstdc++ issue on RHEL 5.7

I would like to create a statically linked binary with the following command:
g++ -o bin/target_binary objs/obj1.o objs/obj2.o objs/obj3.o -I/usr/include/c++/4.1.1/ -O3 -Wall -static -static-libstdc++ -static-libgcc -L /usr/lib/gcc/x86_64-redhat-linux/4.1.1/32 -Wl,-verbose
The relevant part of the output:
attempt to open /usr/lib/gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.a succeeded
attempt to open /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libstdc++.a failed
attempt to open /usr/lib/gcc/x86_64-redhat-linux/4.1.2/libstdc++.a failed
attempt to open /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libstdc++.a failed
attempt to open /lib/../lib64/libstdc++.a failed
attempt to open /usr/lib/../lib64/libstdc++.a failed
attempt to open /usr/x86_64-redhat-linux/lib64/libstdc++.a failed
attempt to open /usr/local/lib64/libstdc++.a failed
attempt to open /lib64/libstdc++.a failed
attempt to open /usr/lib64/libstdc++.a failed
attempt to open /usr/x86_64-redhat-linux/lib/libstdc++.a failed
attempt to open /usr/lib64/libstdc++.a failed
attempt to open /usr/local/lib/libstdc++.a failed
attempt to open /lib/libstdc++.a failed
attempt to open /usr/lib/libstdc++.a failed
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-51)
uname -a
Linux vmh-caipi-reporting.lsy.fra.dlh.de 2.6.18-274.18.1.el5 #1 SMP Fri Jan 20 15:11:18 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.7 (Tikanga)
Release: 5.7
Codename: Tikanga
What is wrong?
Thanks in advance!
/usr/bin/ld: cannot find -lstdc++
The problem seems to be that you have 32-bit libstdc++.a, but not a 64-bit one.
Find out where the 32-bit version came from: rpm -qf /usr/lib/gcc/x86_64-redhat-linux/4.1.1/32/libstdc++.a, and try to install equivalent 64-bit package.
If there is no existing package that provides 64-bit libstdc++.a (that's very unlikely), you can grab the source RPM for your gcc, and rebuild it. That should give you a usable 64-bit version of libstdc++.a.

C++11 not Working with Macports gcc47

I recently installed Macports on my Macbook Pro, and installed the gcc47 port. After adding alias g++="g++-mp-4.7" to my .profile and ensuring that I was using g++-4.7, I attempted to build one of my projects that makes use of C++11. However, I receive this error:
cc1plus: error: unrecognized command line option "-std=c++11"
I find this strange, since Macports built gcc with support for C++, so I would expect that C++11 should work without any problems. I have pasted the output from g++ -v below. Do you have any ideas as to why g++-mp-4.7 is not recognizing -std=c++11 as a valid option?
COLLECT_GCC=g++-mp-4.7
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.7.1/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.7.1/configure --prefix=/opt/local --build=x86_64-apple-darwin12 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --enable-stage1-checking --disable-multilib --enable-lto --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.1_2'
Thread model: posix
gcc version 4.7.1 (MacPorts gcc47 4.7.1_2)
For future reference, if you install gcc_select you can do:
sudo port select gcc mp-gcc47
hash gcc
This should setup your Macports installed gcc; if you need to reset to Xcode's default, just rerun it with 'none'
EDIT: and Xcode 4.4.x comes with a decent build of Clang; if you install it and then from Preferences->Downloads: Command Line Tools click "Install"
Run clang as:
clang++ -std=c++11 -stdlib=libc++ ...
Note that if mp-gcc47 is not installed, you'll need to do this first:
sudo port install mp-gcc47
To get a full list of available gcc ports:
sudo port list | grep gcc | less
My problem was that since GNU Make executes commands in a different shell, alias g++="g++-mp-4.7" will have no effect on the commands executed by make.