问题
I faced a problem with loading a dynamic library with dlopen()
:
I attempt to load a library:
handle = dlopen("libmkl_intel_lp64.so", RTLD_LAZY);
This code fails with the following message from dlerror()
:
/opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_intel_lp64.so: undefined symbol: mkl_vsl_serv_threader_for
I know that this symbol can be found in another library, libmkl_gnu_thread.so
for example. If use LD_PRELOAD
to load that library the above mentioned error on undefined symbol goes away. But how do I make this symbol available without using LD_PRELOAD
?
In case of explicit linking I would list all the libraries but I'm not sure what the logic is in my case of using dlopen()
回答1:
You need to add a dependency to your .so file. These dependencies are shown with the ldd
command. They are added in several ways - most common is when compiling your .so, add -l<dep>
to add a dependency to <dep>.so
.
来源:https://stackoverflow.com/questions/25201860/resolving-dynamic-libraries-dependencies-when-loading-with-dlopen