Free Downloads, Community Forum,
FAQs and Developer Resources


Make /Tools Your Home | Link to us

Today's posts | Posts since last visit | Most Active Topics

All Forums Register Login Search Subscriptions My Profile Inbox
Tool Warehouse FAQs Resources Help Member List Address Book Logout

dlopen + dlsym problem

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum >> dlopen + dlsym problem Page: [1]
Login
Message << Older Topic   Newer Topic >>
dlopen + dlsym problem - Mar. 8, '06, 6:38:18 AM   
kingbing

 

Posts: 8
Joined: Sep. 20, '05,
Status: offline
Hi folks. I'm trying to build something using libglade, which sits on top of gtk. It's got a nice feature where it will automatically wire up events to event handlers (you specify an xml file that describes the interface, and the functions it calls when things happen).

This all works via dlopen/dlsym (via gmodule in glib), but this doesn't seem to work in Interix.

If you call dlopen(NULL,0) you should get a handle back to all the symbols in the current image. Calling dlsym from that should get you the address of a function in your own program. Unfortunately, it doesn't work - dlsym can only find items in shared libraries loaded by the current image.

Here's an example program:

#include <dlfcn.h>

int glib_underscore_test(void) { return 42; }
int main()
{
int i=glib_underscore_test();
void *f1=(void *)0, *f2=(void *)0, *handle;
handle=dlopen((void*)0,0);
if(handle)
{
f1=dlsym(handle,"dlsym");
if(!f1)
printf("%s\n",dlerror());
f1=dlsym(handle,"glib_underscore_test");
if(!f1)
printf("%s\n",dlerror());
f2=dlsym(handle,"_glib_underscore_test");
if(!f2)
printf("%s\n",dlerror());
}
else
printf(dlerror());
}

On my box, the call to find "dlsym" does not cause an error, but the calls to find "glib_underscore_test" and "_glib_underscore_test" do.

Anyone got any ideas?

Cheers
Matt
Post #: 1
RE: dlopen + dlsym problem - Mar. 10, '06, 11:24:22 AM   
kingbing

 

Posts: 8
Joined: Sep. 20, '05,
Status: offline
Sorted. From the man page to ld:

-E, --export-dynamic
When creating an ELF file, add all symbols to the dynamic-symbol
table. Normally, the dynamic-symbol table contains only symbols that
are used by a dynamic object. This option is needed for some uses of
dlopen(3).

Just add --export-dynamic to the Makefile and everything's lovely.

Cheers!
Matt

(in reply to kingbing)
Post #: 2
Page:   [1]
All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum >> dlopen + dlsym problem Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Search All Forums -

Advanced search


SPONSORS



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.078