public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* calling a function of a shared library from another shared library
@ 2012-01-05 17:57 Benjamin Raverdy
  2012-01-05 18:36 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Raverdy @ 2012-01-05 17:57 UTC (permalink / raw)
  To: gcc-help

Hi,

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.

Regards,

(Sorry I have posted this on other places in the gcc mailing lists 
before finding this one)


-- 
Benjamin Raverdy

VFX software engineer
La Maison
13-15 rue Gaston Latouche
92 210 Saint-Cloud. France
email: b.raverdy@alamaison.fr
phone: 01.41.12.20.27

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: calling a function of a shared library from another shared library
  2012-01-05 17:57 calling a function of a shared library from another shared library Benjamin Raverdy
@ 2012-01-05 18:36 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2012-01-05 18:36 UTC (permalink / raw)
  To: Benjamin Raverdy; +Cc: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-05 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-05 17:57 calling a function of a shared library from another shared library Benjamin Raverdy
2012-01-05 18:36 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).