![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Posts: 18
Rep Power: 0
![]() |
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...). |
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 600
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jun 2005
Posts: 18
Rep Power: 0
![]() |
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... |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|