OS: CentOS 7 x86_64
I am working on a C (later ADA) cross-compiler from x86_64
to PowerPC32
. CentOS 7
has a cross-compiler already built in its default repository, so through yum
, I ran
yum install gcc-powerpc64-linux-gnu.x86_64
Although this is a ppc64
compiler, I can pass a flag to force 32-bit
mode so for now, that does not worry me. I just want to get it compiling even in 64-bit mode.
I am trying to compile the following hello world program:
#include <stdio.h>
int main()
{
printf("Hello, World!");
return 0;
}
When I ran this with regular gcc
, it compiles and runs just fine. The problem is that when compiling I get the error mentioned above.
Here is the output of the compilation command
[root@dev cross-compil-tests]# powerpc64-linux-gnu-gcc -o hello hello.c -v
Using built-in specs.
COLLECT_GCC=powerpc64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/powerpc64-linux-gnu/4.8.5/lto-wrapper
Target: powerpc64-linux-gnu
Configured with: ../gcc-4.8.5-20150702/configure --bindir=/usr/bin --build=x86_64-redhat-linux-gnu --datadir=/usr/share --disable-decimal-float --disable-dependency-tracking --disable-gold --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-nls --disable-plugin --disable-shared --disable-silent-rules --disable-sjlj-exceptions --disable-threads --enable-checking= --enable-gnu-unique-object --enable-initfini-array --enable-languages=c,c++ --enable-linker-build-id --enable-nls --enable-obsolete --enable-targets=all --exec-prefix=/usr --host=x86_64-redhat-linux-gnu --includedir=/usr/include --infodir=/usr/share/info --libexecdir=/usr/libexec --localstatedir=/var --mandir=/usr/share/man --prefix=/usr --program-prefix=powerpc64-linux-gnu- --sbindir=/usr/sbin --sharedstatedir=/var/lib --sysconfdir=/etc --target=powerpc64-linux-gnu --with-bugurl=http://bugzilla.redhat.com/bugzilla/ --with-linker-hash-style=gnu --with-newlib --with-sysroot=/usr/powerpc64-linux-gnu/sys-root --with-system-libunwind --with-system-zlib --without-headers --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/cloog-install --with-cpu-32=power4 --with-tune-32=power6 --with-cpu-64=power4 --with-tune-64=power6 --enable-secureplt --with-long-double-128
Thread model: single
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
COLLECT_GCC_OPTIONS='-o' 'hello' '-v' '-mtune=power6' '-mcpu=power4'
/usr/libexec/gcc/powerpc64-linux-gnu/4.8.5/cc1 -quiet -v -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix hello.c -msecure-plt -quiet -dumpbase hello.c -mtune=power6 -mcpu=power4 -auxbase hello -version -o /tmp/ccwki2NC.s
GNU C (GCC) version 4.8.5 20150623 (Red Hat 4.8.5-16) (powerpc64-linux-gnu)
compiled by GNU C version 4.8.5 20150623 (Red Hat 4.8.5-11), GMP version 6.0.0, MPFR version 3.1.1, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/powerpc64-linux-gnu/sys-root/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/powerpc64-linux-gnu/4.8.5/../../../../powerpc64-linux-gnu/include"
ignoring nonexistent directory "/usr/powerpc64-linux-gnu/sys-root/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/powerpc64-linux-gnu/4.8.5/include
/usr/lib/gcc/powerpc64-linux-gnu/4.8.5/include-fixed
End of search list.
GNU C (GCC) version 4.8.5 20150623 (Red Hat 4.8.5-16) (powerpc64-linux-gnu)
compiled by GNU C version 4.8.5 20150623 (Red Hat 4.8.5-11), GMP version 6.0.0, MPFR version 3.1.1, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 0af58e346ee6cfd1f5beece8a365542e
hello.c:1:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
These lines are of interest to me
[...]
ignoring nonexistent directory "/usr/powerpc64-linux-gnu/sys-root/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/powerpc64-linux-gnu/4.8.5/../../../../powerpc64-linux-gnu/include"
ignoring nonexistent directory "/usr/powerpc64-linux-gnu/sys-root/usr/include"
[...]
hello.c:1:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
The ignoring nonexistent directory entries might be the problem. I do not know how to fix it, and have removed/reinstalled the cross-compiler multiple times. I also cannot find a C library for the cross-compiler that I can download so that I can link it manually with the -I
flag.
Attempted Solutions
I did a:
find stdio.h | grep stdio.h
and linked the directory of where I found it using -I
. New error, could not find stubs-32.h
... Well ok, fixed that through some more googling (simple yum install) and then I got crt1.o
not found... etc. Frustrating, but I believe this was not the correct direction to go anyways.
here is the ones my computer found
[root@lxdev-gab gnu]# find "stdio.h" / | grep "stdio.h"
find: ‘stdio.h’: No such file or directory
/usr/include/bits/stdio.h
/usr/include/stdio.h
/usr/include/c++/4.8.2/tr1/stdio.h
/usr/share/man/man0p/stdio.h.0p.gz
Any suggestions?