dlsym problem on MacOSX (code works in Linux, fails on MacOSX)

dlsym problem on MacOSX (code works in Linux, fails on MacOSX)

Post by gazell » Thu, 29 Jul 2010 06:26:28


I have an app that uses dlsym() to lookup functions and then executes
them. Usually, the function being lookedup is in the system libraries
(i.e., libc) - i.e., it is a normal function, like read() or write(),
etc. However, sometimes, the function being lookedup is actually in the
app itself - i.e., we use the dlsym mechanism to invoke a "local"
function.

The former case works fine in all 3 OSs, but...
The later case (where the function is in the app itself) works fine in
Linux and Solaris, but fails (the dlsym() function fails with a "symbol
not found" error) in MacOSX.

Any ideas why? How to fix?

--
Just for a change of pace, this sig is *not* an obscure reference to
comp.lang.c...
 
 
 

dlsym problem on MacOSX (code works in Linux, fails on MacOSX)

Post by David Schw » Thu, 29 Jul 2010 06:32:00

On Jul 27, 2:26m, XXXX@XXXXX.COM (Kenny McCormack)


Can you post a complete, compilable example that fails on OSX? And can
you include the command line you used to compile/link it?

DS

 
 
 

dlsym problem on MacOSX (code works in Linux, fails on MacOSX)

Post by Golden Cal » Thu, 29 Jul 2010 10:03:00


Not sure if it is the same issue, but I did find one time that in a MacOSX
program I was working on, a local symbol was automatically changed behind
my back. IIRC an underscore had been prepended. Before you go crazy
compile with debugging symbols on and dump the generated symbol table to be
sure it isn't the same thing.
 
 
 

dlsym problem on MacOSX (code works in Linux, fails on MacOSX)

Post by gazell » Sat, 31 Jul 2010 23:42:55

In article <i2nvk7$6ot$ XXXX@XXXXX.COM >,



My guess is that it is something like this. I tried prepending
underscore(s), but it didn't help.

Anyway, anyone know a general answer - i.e., something like "Oh yeah,
that is not supported under MacOSX" or "You need to be running at least
Service Pack xxx for it to work". That's the sort of answer I was
hoping for.

--
Faced with the choice between changing one's mind and proving that there is
no need to do so, almost everyone gets busy on the proof.

- John Kenneth Galbraith -