This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: calling a function of a shared library from another shared library


Benjamin Raverdy <b.raverdy@alamaison.fr> writes:

> I have a main application (lmApplication) (compiled with the -rdynamic
> option) calling a dynamically shared lirbary, that is calling back
> lmFromCaller() that belong to lmApplication.
> lmApplication --------------------------------> lmLib.so
>                    dyn load with dlopen           |
>                                                   |
> LmFromCaller() <-----------------------------------
> As I use rdynamic, that works fine.
>
> Now I want to do something similar, but having a shared library
> lmPlugin.so instead of the main application.
> Hence I have a main application (lmApplication) calling a dynamically
> shared lirbary lmPlugin.so.
> This plugin is itself calling another shared library lmLib.so that
> calls the method LmFromCaller() of lmPlugin.so
>
> lmApplication  --------> lmPlugin.so ------------------------> lmLib.so
>          dyn load with dlopen      dyn load with dlopen           |
>                                                                   |
>                        lmFromCaller() <----------------------------
>
> I get an error, spite I compiled everything with the -rdynamic option:
> ./test: symbol lookup error:
> /home/benjaminr/Desktop/example_dynamic_load/LmLib/Debug/liblmLib.so:
> undefined symbol: _Z32lmFromCallerv
>
> If you would find it useful to understand my attempts, I can give you
> the code and the way I compiled it.

First step: use "readelf -s --wide" to look at the executable and the
libraries, and find out where the symbol is defined.

I assume you are passing RTLD_GLOBAL to both dlopen calls?

If those ideas don't suggest anything, try setting LD_DEBUG=all in the
environment before starting your program and examining the output around
the point of the error.

By the way, the -rdynamic option is not necessary when linking a shared
library, only when linking an executable.  But it should do no harm.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]