I'm trying to link Andi Kleen's glibc implementation to enable lock-elision for a program with pthreads. I link my program as follows:
g++ \
-Wl,--rpath=/path/glibc-elision/build/lib \
-Wl,--dynamic-linker=/path/glibc-elision/build/lib/ld-linux-x86-64.so.2 \
-o program program.o \
-fgnu-tm -mrtm -pthread \
-Wl,--no-as-needed --enable-lock-elision=yes
As long as I don't use any components of the libstdc++, everything works fine.
But as soon, as e.g. std::vector
is referenced, the dynamic linker can't find the libstdc++.so.6 (error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
).
To resolve this error, I tried to provide the custom as well as the standard glibc with -Wl,--rpath=/path/glibc-elision/build/lib;/usr/lib/x86_64-linux-gnu/libstdc++.so.6
.
This is not the correct call but the idea is to somehow provide both libraries.
So the question is:
How to link a program against different components of two glibcs?
I'm working on Ubuntu 13.10 with gcc (Ubuntu/Linaro 4.8.1-10ubuntu8) 4.8.1.
Thanks to Nemo's comment, the issue could be resolved by appending the C++ runtimes to the rpath. In my case, that is
-Wl,--rpath=/path/glibc-elision/build/lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu
The paths can be set by using export LD_LIBRARY_PATH=/your/path
as well.
It also turns out that I falsely used ;
instead of :
to append the paths in the original post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With