Reputation: 153
i build and installed gcc-4.6.4 into my home dir (i don't have root proviliges). When I link a few object files to an executable with g++, it links the "wrong" libstdc++.so.6.
It does not use the newer one wich is located in the install dir but the one of the system.
Is there a way to specify an exclusive search path for libraries?
My bashrc:
PATH=$PATH:/home/testuser/selfcompiled/gcc-4.6.4/bin:/usr/local/cuda/bin
export PATH
C_INCLUDE_PATH=/home/testuser/selfcompiled/gcc-4.6.4/include
export C_INCLUDE_PATH
CPLUS_INCLUDE_PATH=/home/testuser/selfcompiled/gcc-4.6.4/include
export CPLUS_INCLUDE_PATH
LIBRARY_PATH=/home/testuser/selfcompiled/gcc-4.6.4/lib:/home/testuser/selfcompiled/gcc-4.6.4/lib64/lib
export LIBRARY_PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/local/cuda/cudaprof/bin:/home/testuser/selfcompiled/gcc-4.6.4/lib:/home/testuser/selfcompiled/gcc-4.6.4/lib64/lib
export LD_LIBRARY_PATH
GCC_EXEC_PREFIX=/home/testuser/selfcompiled/gcc-4.6.4/lib/gcc/
export GCC_EXEC_PREFIX
COMPILER_PATH=/home/testuser/selfcompiled/gcc-4.6.4/bin/:/home/testuser/selfcompiled/gcc-4.6.4/libexec/:/home/testuser/selfcompiled/gcc-4.6.4/lib/gcc/
export COMPILER_PATH
Even if I specify the dir with the local libstdc++.so.6 via g++ -L...., the one located in /usr/... is linked to the executable according to ldd.
Thanks very much!
Upvotes: 0
Views: 431
Reputation: 213375
I am guessing you have built 64-bit executable. This path:
/home/testuser/selfcompiled/gcc-4.6.4/lib64/lib
looks wrong, and should likely be:
/home/testuser/selfcompiled/gcc-4.6.4/lib64
To use it, set LD_LIBRARY_PATH
, or better use -Wl,-rpath=/home/testuser/selfcompiled/gcc-4.6.4/lib64
Upvotes: 0
Reputation: 76519
Nothing goes wrong when linking (or you'd get a linker error to symbols not present in the old library version).
This is a runtime thing. This:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/local/cuda/cudaprof/bin:/home/testuser/selfcompiled/gcc-4.6.4/lib:/home/testuser/selfcompiled/gcc-4.6.4/lib64/lib
export LD_LIBRARY_PATH
Should be
LD_LIBRARY_PATH=/home/testuser/selfcompiled/gcc-4.6.4/lib:/home/testuser/selfcompiled/gcc-4.6.4/lib64/lib:$LD_LIBRARY_PATH:/usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/local/cuda/cudaprof/bin
export LD_LIBRARY_PATH
The executable loader needs to look at your new libraries first, before it looks at the old ones. Of course, there is strong binary compatibility, so if no new symbols are used, the old libs will do just fine.
Upvotes: 1