linux dlopen can not find static library's symbol

百般思念 提交于 2019-12-11 21:17:37

问题


I have an executable project which uses a shared library, that includes a static library. Then from the executable, I try to load another shared library with dlopen. That library is found but it cannot find symbols from static library.

Here is the structure:

-- SHARED LIB 1
   -- (compiled with) Static Lib 1

-- EXECUTABLE
   -- SHARED LIB 1
   -- dlopen SHARED LIB 2  XX ERROR: SHARED LIB 2 cannot find symbols of Static Lib 1

Both SHARED LIB 1 and SHARED LIB 2 are linked from /usr/lib.

It seems that I miss some flags.

How could I solve this issue?


回答1:


what flags are used to build the "SHARED LIB 1"? AFAIK -fvisibility won't affect static libs.

However if you use --exclude-libs on linking, the "Static Lib 1"s symbol will be removed.

Hope this Question may help: How to apply gcc -fvisibility option to symbols in static libraries?



来源:https://stackoverflow.com/questions/32649337/linux-dlopen-can-not-find-static-librarys-symbol

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