The server I want to run some code on has older versions of gcc (gmp, mpc, mpfr too) installed in the standard locations like /usr*
the admin is unwilling to update but has allowed me to install a newer version of gcc in my /home/username
directory. I have done this an now have g++d46
as gcc 4.6.3 installed in my home dir /home/myusername/opt2/gcc-4.6.3
. I also have gmp,mpfr,mpc installed in /home/myusername/tmp/gcc/{include,lib,share}
.
I have exported {LD_LIBRARY_PATH, LIBRARY_PATH,LD_RUN_PATH}=/home/myusername/tmp2/gcc/lib:/home/myusername/opt2/gcc-4.6.3/lib/gcc/x86_64-unknown-linux-gnu/4.6.3:/home/myusername/opt2/gcc-4.6.3/lib64:
and PATH=/bin:/usr/bin:/home/myusername/opt2/gcc-4.6.3/bin:
also {C_INCLUDE_PATH,CPLUS_INCLUDE_PATH}=/home/myusername/tmp2/gcc/include:/home/myusername/opt2/gcc-4.6.3/include/c++/4.6.3:
I then compile some test code with
g++d46 -g -O3 -I/home/myusername/tmp2/gcc/include -L/home/myusername
/tmp2/gcc/lib -Wall testMPFR3.cpp -o myBin -lgmp -lgmpxx -lmpfr
which compiles and executes OK, but upon doing ldd myBin
I see that despite being mostly linked with the correct libs on my home directory, we also have:
libm.so.6 => /lib64/libm.so.6 (0x0000003917e00000)
libc.so.6 => /lib64/libc.so.6 (0x0000003917a00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003917600000)
which are not on my home dir, how does it even know to look elsewhere, given the env vars I have exported and my -I
and -L
flags?
Also if I do g++ -H
to see where the headers are coming from, again most (including the new gmp, mpfr thankfully) are coming from my home dir, but a few:
..... /usr/include/sys/cdefs.h
...... /usr/include/bits/wordsize.h
..... /usr/include/gnu/stubs.h
...... /usr/include/bits/wordsize.h
...... /usr/include/gnu/stubs-64.h
........ /usr/include/stdio.h
........ /usr/include/bits/wchar.h
........ /usr/include/xlocale.h
....... /usr/include/locale.h
..... /usr/include/ctype.h
....... /usr/include/bits/types.h
........ /usr/include/bits/wordsize.h
........ /usr/include/bits/typesizes.h
....... /usr/include/endian.h
........ /usr/include/bits/endian.h
........ /usr/include/pthread.h
......... /usr/include/sched.h
.......... /usr/include/time.h
.......... /usr/include/bits/sched.h
......... /usr/include/time.h
.......... /usr/include/bits/time.h
......... /usr/include/signal.h
.......... /usr/include/bits/sigset.h
......... /usr/include/bits/pthreadtypes.h
.......... /usr/include/bits/wordsize.h
......... /usr/include/bits/setjmp.h
.......... /usr/include/bits/wordsize.h
I don't understand why my local gcc-4.6.3 is missing these? nor how the linker knows to revert to /usr/*
if it doesn't find them on the home dir?
I could use the flag --nostdinc
upon compilation perhaps, but this probably won't solve the problem that the above headers can't be found locally for some reason.