Aleksandar Ristovski(deleted)
|
Re: dlopen fails but not a helpful dlerror response
|
Aleksandar Ristovski(deleted)
07/20/2015 3:39 PM
post114147
|
Re: dlopen fails but not a helpful dlerror response
Symbols are resolved within their resolution scope. This is not dependent
on the calling thread, only on the resolution scope.
To start troubleshooting, I suggest collecting 'resolution scopes' from
the LD_DEBUG logs.
Observe which object *defines* the unresolved symbol(s). This object,
let's call it lbFOO, needs to appear in the resolution scope of MODBUS
since MODBUS library needs the symbol.
Normally, you would add libFOO as a dependency to MODBUS. However, if you
can not change MODBUS, then there are a few options:
From what you are describing, I would expect that the working "thread"
(shared object) lists needed dependency libFOO as its own dependency and
it gets included in MODBUS resolution scope; MODBUS then gets the symbol
from it.
In the non-working scenario the said object (libFOO) does not get pulled
in the resolution scope and the symbol remains unresolved.
To include libFOO in the resolution scope, there a are a few scenarios (as
a workaround to the ideal, which is adding all needed libraries to MODBUS
library).
A) Assuming your "threads" - shared objects link against MODBUS (as
opposed to dlopening it), you can remedy the situation by adding defining
object to the non-working shared object NEEDED list (you add libFOO as a
library passed to the linker 'ld').
B) Another workaround is to link your defining library to your executable.
That way, it will end up in the resolution scope of MODBUS. You dlopen
your objects with '0' passed as flags.
C) you can explicitly dlopen the defining object with
RTLD_GROUP|RTLD_GLOBAL|RTLD_WORLD flags, but you have to do this *before*
any dlopen(MODBUS). Then, dlopen of MODBUS must contain
RTLD_GLOBAL|RTLD_WORLD to pull in the object dlopened above.
If the above doesn't help, please post more detail: which symbol was not
resolved, which shared object defines it, and portions of the LD_DEBUG
output listing "Resolution scope" for each of the 'thread' shared objects
- working and non working ones. Also, which exactly OS version are you
using.
HTH,
Aleksandar
|
|
|