Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - dlopen fails but not a helpful dlerror response: Page 1 of 5 (5 Items)
   
dlopen fails but not a helpful dlerror response  
Any ideas how to get a useful error message from the dynamic library loading facility? I have an issue where the 
debugger is loading my library into /opt/target and my code is calling dlopen with the correct name. I get NULL back 
from the call and the error string from dlerror() is "(Shared objects still referenced)"

As you can see, it is not terribly useful in figuring out what the OS thought was wrong. I have verified that the 
permissions are correct (777) and the name is spelled correctly so it is not permissions or a bad name.

With fopen() you get an error such as E_EXIST or other useful detailed information.
Here is the offending code:
	void *Library=dlopen(Path.c_str(), RTLD_NOW | RTLD_NODELETE);
	if ( Library==NULL )
        {
		char *ErrorStr=dlerror();
		printf( "%s::%s(): ERROR - failed to load '%s' (%s)\n",
				CLASS_NAME, __FUNCTION__, Path.c_str(), ErrorStr);
	}
And here is the output:
IComponent::RegisterDynamic(): ERROR - failed to load '/opt/target/libModbusTransceiver_g.so' (Shared objects still 
referenced)

Any hints on how to find the real error are appreciated. My guess is that there is some error with the format of the 
library since the file exists and the name in the call matches the name on disk.

Ray