Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 19th, 2005, 11:18 AM   #1
earl
Newbie
 
Join Date: Jun 2005
Posts: 18
Rep Power: 0 earl is on a distinguished road
Visual C++ - DLLs reverse resolve symbols

Does anybody know how to create DLLs with VC++ 6.0 such that it will reverse resolve symbols? I'm getting a linker error obviously, because the function I want the DLL to use is defined in the program that loads it.

I've been able to do this on various UNIX systems, either using g++ or native compilers/linkers. It usually required special flags, but I'm not sure how to make this work with VC++. Any ideas?

Using the dlopen() functionality, as long as the main module exported symbols, the DSO library was able to call these functions using normal syntax once the module was loaded. I'm assuming this should be true for Windows DLLs as well, but first I need to get the DLL to link without having this symbol defined.

(BTW, I'm aware having a DLL depend on symbols from the program that loads it is not exactly good practice. :p I'm just testing this...).
earl is offline   Reply With Quote
Old Jun 19th, 2005, 12:59 PM   #2
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 600
Rep Power: 4 Ancient Dragon is on a distinguished road
one technique frequently used is callback functions. write a dll function that allows the application program to send it a function pointer, then the dll can just call that pointer when needed. There are no linking issues by doing that.
Ancient Dragon is offline   Reply With Quote
Old Jun 19th, 2005, 6:12 PM   #3
earl
Newbie
 
Join Date: Jun 2005
Posts: 18
Rep Power: 0 earl is on a distinguished road
Thanks AD. That solution wasn't as easy due to the nature of what I'm working on, but you nudged me in the right direction. The situation involves some symbols in a main module that need to be shared globally throughout many modules, and are accessed in a template class as well as another class embedded in that class.

I basically got around this by declaring some global pointers in that header file and putting the pertinent data in its own DLL (rather than main). The access functions check for NULL on those pointers and load the mini-DLL when appropriate. The class I'm playing with is a smart pointer class so I wanted it to more "take care of itself" rather than adding "initialize" type functions that require passing in function pointers.

I'm still interested in finding a way to do this without having to make this extra DLL. The way I described before I've got to work on Solaris, Linux, AIX and HP-UX, so I'd figure there should be a way to get the libraries to link in Windows as well, but I'm not as familiar with Windows and haven't come up with much from googling...
earl is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC