Why can't my cross-compiler g++ find header files?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Why can't my cross-compiler g++ find header files?

Post by mariuszp »

I have configured GCC as follows:

Code: Select all

../glidix-gcc/configure --target=x86_64-glidix --prefix=/glidix/usr --with-sysroot=/glidix --enable-languages=c,c++ --exec-prefix=/usr --disable-nls
I built and installed GCC and the C++ standard library, using:

Code: Select all

make all-gcc all-target-libgcc
make install-gcc install-target-libgcc
make all-target-libstdc++-v3
make install-target-libstdc++-v3
The C++ headers were installed in "/glidix/usr/x86_64-glidix/include/c++/4.9.0". However, when attempting to compile the trivial "hello world" in C++, I get:

Code: Select all

$ x86_64-glidix-g++ hello.cpp -o hello
hello.cpp:1:20: fatal error: iostream: No such file or directory
 #include <iostream>
                    ^
compilation terminated.
So I decided to pass the "-v" flag to see what is happening:

Code: Select all

$ x86_64-glidix-g++ hello.cpp -o hello -v
Using built-in specs.
COLLECT_GCC=x86_64-glidix-g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-glidix/4.9.0/lto-wrapper
Target: x86_64-glidix
Configured with: ../glidix-gcc/configure --target=x86_64-glidix --prefix=/glidix/usr --with-sysroot=/glidix --enable-languages=c,c++ --exec-prefix=/usr --disable-nls
Thread model: single
gcc version 4.9.0 (GCC) 
COLLECT_GCC_OPTIONS='-o' 'hello' '-v' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-glidix/4.9.0/cc1plus -quiet -v hello.cpp -quiet -dumpbase hello.cpp -mtune=generic -march=x86-64 -auxbase hello -version -o /tmp/ccaFVvJA.s
GNU C++ (GCC) version 4.9.0 (x86_64-glidix)
	compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-glidix/4.9.0/../../../../../x86_64-glidix/include/c++/4.9.0"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-glidix/4.9.0/../../../../../x86_64-glidix/include/c++/4.9.0/x86_64-glidix"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-glidix/4.9.0/../../../../../x86_64-glidix/include/c++/4.9.0/backward"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-glidix/4.9.0/../../../../../x86_64-glidix/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-glidix/4.9.0/include
 /glidix/usr/local/include
 /usr/lib/gcc/x86_64-glidix/4.9.0/include-fixed
 /glidix/usr/include
End of search list.
GNU C++ (GCC) version 4.9.0 (x86_64-glidix)
	compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 1308ca13ef78229dce86638bb09addb3
hello.cpp:1:20: fatal error: iostream: No such file or directory
 #include <iostream>
                    ^
compilation terminated.
It is pretty clear that it is not looking for the C++ library where it should be. If I add that directory to the include path explicitly with "-I", I get errors about other headers not being found. My native linux g++ has all the linux C++ headers in its path, so why does the cross-compiler to glidix not have them?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Why can't my cross-compiler g++ find header files?

Post by pcmattman »

You may want to try not setting, or otherwise fixing, exec-prefix (as that then affects GCC's --libdir, et al):

Code: Select all

ignoring nonexistent directory "/usr/lib/gcc/x86_64-glidix/4.9.0/../../../../../x86_64-glidix/include/c++/4.9.0"
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: Why can't my cross-compiler g++ find header files?

Post by mariuszp »

If I don't set the --exec-prefix, that would mean it would install the binaries in /glidix/usr/bin, so I'd have to add that to PATH whenever I want to use the compiler.
Post Reply