0
votes

I have a program structure that has

static library(ACE)

static library(common.a)

dynamic library plugin 1(1.so)

plugin 2(2.so) and executable

plugin1, plugin2 and executable all use both common.a and libACE.a Follow the tutorial here: http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html.

I only link those two static library when compiling the executable as shown below:

g++  -g -DUNIX -DLINUX   -Wall -D__NUMBER_FIELD_ID__ -I/opt/ACE_wrappers -Ilib/ -I. -I./common -I./common/lib -I../inc -I/opt/pct/pctlib/inc -o acs_d acs_d.o  -L../lib  -Wl,--export-dynamic -rdynamic -Wl,--whole-archive /opt/ACE_wrappers/ace/libACE.a  common/libcommon_d.a -Wl,--no-whole-archive -ldl -lrt -lpthread

The point is, when I use dlopen to open those two plugins, one succeeds and one fails The successful one use more ACE functions and the error is complaining undefined symbol as shown below:

[CModuleMgr] loadCModule(): Errors occurred when opening the module. nCModuleId[1] pLibHandle[(nil)] sCModulePath[/opt/acs/adapter/libadapter_d.so] sError[/opt/acs/adapter/libadapter_d.so: undefined symbol: _ZN17ACE_Event_Handler10set_handleEi]

For the main program, I have tried to use command nm to find the symbol

$ nm acs_d | grep _ZN17ACE_Event_Handler10set_handleEi
000000000048f240 t _ZN17ACE_Event_Handler10set_handleEi

It is there, but the plugin cannot find it! I have used option like -Wl,--export-dynamic -rdynamic -Wl,--whole-archive. But it still cannot find this symbol. any idea?

1

1 Answers

0
votes

It is there, but the plugin cannot find it!

No, the symbol is not there!

Or rather, the symbol has internal linkage (t), and is not visible or usable outside of the ELF image into which it is linked. Globally visible symbols have external (T) linkage.

The most likely cause for the symbol to have t linkage is that the symbol has __attribute__((visibility("hidden"))) at the source level. Documentation here.

Why ACE developers marked it as such, I don't know.