shared libraries - Receive "undefined symbol" error when loading library with dlopen -


I am writing some code that uses dynamic shared libraries as plugins.

My command line for building looks like shared libraries:

  cc -shared -fPIC -o module.so -g-wall module.c  

Within the module, I can call the function that is in another shared library that is loaded in the main executable.

Although I have the executable function (i undefined symbol errors).

dlopen My call looks like this:

  zero * handle = DLPN (plugin, RTLD_NOO); Can someone please advise how can my modules call back to my executable, without putting all executable utility functions into another shared library?   

The right solution to add -dynamic to the main executable link command It will add the appropriate option for ld (which happens to be - export-dynamic when using GNU ld ).

is technically incorrect: adding - export-dynamic is a linkir option, and so it is -Wl, - export-dynamic , Or -Wl, -E . It is less portable than - dynamic (equivalent to other linkers, but the options themselves are different).


Comments