I've got a C++ program and some plugins ( shared objects ) that I have been developing for Linux. I was originally using and OSX machine to develop and test most of the code.
I use dlopen to open the shared objects and then call methods from them. It behaves differently on Linux ( don't know the version right now, have to check tomorrow ) vs. OSX ( 10.6 ).
The plugins are the same class & methods exactly, except for a method that returns the plugin name ( see below ).
My main() does dlopen on each of them, finds an Init() method and calls the init method for each, passing a pointer to an api class so Init() can give main() back a handle to the plugin ( via the parent base ).
When main() calls parent->pluginName(), on OSX, it always returns "plugin1" no matter which handle is used. On Linux, the same code returns "plugin1" when that handle is used and "plugin2" when that handle is used.
Now, the OSX result seems correct to me, because that .so is loaded first, but I would still expect a dlopen error when loading the second one.
I know the proper solution is to have different child class names in each plugin - that is going to happen at some point, but I still would like to figure out why OSX and Linux behave differently in this regard.
I'm investigating this myself, but was wondering if someone can shed any light on this?
This looks like a scoping issue. If the names of the two classes are identical, depending on the scope of your symbols at compile and link time, when your Init method creates a new object it can either use the methods from its own shared object or from the first one it finds in the symbol table.
Unless you want to always be chasing down weird issues like this from platform to platform and compiler to compiler and linker to linker, you do not want to depend on symbol scoping to make sure you call the correct method.
The easiest solution is to give each child class a distinct name.
This is an AT A GLANCE shell DEMO that does:-
1) 10 centred greyscale fades without warning beeps.
2) 5 centred yellow "WARNING!" flashes with beeps every ON state.
3) 5 FULL widowed red "DANGER!!!" flashes with beeps in the ON and OFF states.
It assumes that the warning bell is enabled... (0 Replies)
I've attached a tar.gz containing three tests to demonstrate the problem I'm having.
Within the tar are two shared libraries, two test applications, and a Makefile that builds the three tests.
The shared libaries are libshlib1.so and libshlib2.so. Both export a function, libFunc, which takes... (5 Replies)
Hey guys, i am creating a tool that'll run a couple network test, generate a report then email the report. Now i a bit stuck with the email sending part... I tried at first a script which worked on some machines but then it'll work fine on some machine and act up on others... I can't really rely... (2 Replies)
Hi guys!
I'm a regular joe, so this thread might be in the wrong section and if I appear dumb it mostly because I am..and have lack of knowledge about the unix world. :)
Please move the tread if needed.
To the problem.
We are allot of people in the OSx86 community that need a linux driver... (0 Replies)
when i try to run an executable i got the following error message:
resolve_symbols: loader error: dlopen:
what does this error mean and what should be done to avoid this?
with regards (1 Reply)
Hi unix lovers,
I am getting error while compile a function which uses dlopen.
My code is
I am getting error as follows
Am I missing something? I think I am missing a lot :-)
I am using solaris.
Thanks in advance,
-Ashish (5 Replies)
I can open my so file successfully by calling dlopen directly in my main function. But if I fork a child process, and call dlopen in child process, it failed!
I don't know why. Following is my code:
#include <stdio.h>
#include <errno.h>
#include <dlfcn.h>
void childFunc(void)
{
void... (1 Reply)
HI All,
I am trying to use a dll using dlopen but in vain. When I try to ldd that dll it returns no output. Can anybody please tell me how I can load this dll in my process space.
PS: ldd -l returns a lot of unsatisfied dependent symbols.
Thanks a lot in advance
Codeman (0 Replies)