Resolving dynamic libraries dependencies when loading with dlopen()

余生长醉 提交于 2020-05-29 07:19:51

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!