Problem with generating dylib
  #1 (permalink)  
Old 09-11-2008, 11:40 AM
Hannes Hannes is offline
Junior Member
 
Join Date: Sep 2008
Posts: 1
Default Problem with generating dylib

Hey,

i am currently trying to build a dylib which should be used as a plugin for another program. It should only have the function "RegisterPlugins()" visible to the Program which loads the plugin. I have nearly tried all possible settings in XCode, but unfortunatelly with no success so far

Here comes the declaration of the function:

Code:
__attribute__((visibility("default"))) void RegisterPlugins()
{
     // my function body
}
And here the code which tries to load this function into the program:

Code:
		// load dylib into address space
		void* dylibHandle = dlopen( filename, RTLD_GLOBAL );
		if (dylibHandle == NULL) 
		{
			LogError("Failed to load the plugin library file (code=%d)", dlerror());
			return false;
		}
		
		// get the address to the RegisterPlugins function inside the plugin
		typedef void (*RegisterFunction)();
		RegisterFunction registerFunction = (RegisterFunction)dlsym( dylibHandle, "RegisterPlugins" );
		if (registerFunction == NULL)
		{
			LogError("Failed to find the RegisterPlugins function inside this plugin library (code=%d)", dlerror());
			dlclose( dylibHandle );
			return false;	
		}
	
		(registerFunction)();
The opening of the library works fine and also no compile errors. But the registerFunction is always 0. So it tells that it has not found the plugin inside the plugin lib. I have set compileroption: -fvisibility=default which should also make all symbols visible i think. Also experimented with the EXPORTED_SYMBOLS_FILE option, with no success. Also tried the #pragma version of the gcc visibility without success...

Does anyone have an idea which setting could be wrong or what to adjust to get that working??? Hope you can help me. I'm glad about every small hint !!! Thanks in advance!!

Regards, Hannes
Reply With Quote

  #2 (permalink)  
Old 09-11-2008, 08:48 PM
jon jon is offline
Administrator
 
Join Date: Jun 2008
Location: Colorado
Posts: 19
Default

I haven't done any dylib work before so I am not sure if I will be of much help.

What are you doing on that last line of code?

Code:
(registerFunction)();
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump



All times are GMT. The time now is 08:54 PM.


vBulletin skin developed by: eXtremepixels
Powered by vBulletin® Version 3.8.0 Beta 1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27