Re: Dynamic linking with symbols
- From: "James Brown" <remove_james_dot_brown7_at_virgin_dot_net>
- Date: Tue, 30 Aug 2005 20:22:15 +0100
"Philip Lawatsch" <philip@xxxxxxx> wrote in message
news:jmgeu2xvmp.ln2@xxxxxxxxxx
> James Brown schrieb:
>
>>>I have an executable which dllexports a lot of stuff. And a dll which
>>>dllimports it (yes, _really_ this way around).
>>>
>>>The idea is that the dll is a plugin for my exe and thus can use all of
>>>the "symbols" inside my executable.
>>>
>>>Now the problem is that in this case the dll has to link against a
>>>specific executable which in turn makes sure I can't use the same dll in
>>>two different executables.
>>>
>>>Now I could put all the exported code from my executables into a dll and
>>>let my plugin dll and both of my executables link against this dll.
>
>>>Is there anything like this available on Windows?
>
>> I think I just had a brain-spasm reading this but I'll have a go..
>
> :)
>
>> Try putting your "exported code" into a static library which your
>> EXE links against. When you build your multiple exe(s), the linker will
>> include
>> this lib file and generate the exports appropriately - so you can get
>> more
>> than one executable exporting the same set of functions.
>
> Thats what I'm doing of course. But the dll can only import from the one
> it used the export stub from.
>
>> This doesn't provide an easy mechanism for the DLL to import
>> from this DLL though. The problem is that an import library for a DLL
>> (or EXE in this case) relies on knowing the name of the module that you
>> are importing from. So you really have to call your executables by
>> the same base-name otherwise it will be very hard to get working
>> (you will need custom build-steps and that kind of thing).
>
> I was afraid about that. Guess I'll use an addition dll for the exported
> functionality then.
>
>> Comment about the DLL importing from EXE:
>>
>> Personally I would do this differently. Pass a structure full
>> of function-pointers to the DLL (i.e. a bit like a COM interface) - do
>> this
>> when you first initialize the DLL. The DLL just needs to #include a
>> header
>> file which defines this structure and the function-prototypes. It can
>> then
>> call these functions in a portable manner and it doesn't matter *who*
>> passes this
>> structure - it could be a DLL, an EXE or something else.
>> Much easier to maintain/manage/design IMHO.
>
> Not at all. I've got several singeltons and stuff like that. My plugin
> simply registers some callbacks inside these singeltons. Thus I need to
> either pass all the singeltons pointers or pass function pointers to
> functions hooking the callbacks into the singeltons. Not very elegant imo.
>
> Since I'm working with OOP quite a lot I definitly would not want a plugin
> writer to use a c style interface (which you would have to use in your
> example). Plugins will have to work with objects created in my executable
> for instance. Writing c wrappers for these would be a pain.
>
> Imho exporting my core functionality either from the exe or an additional
> dll is the more elegant solution in my case.
>
> kind regards Philip
from what you've described I think your idea of the additional DLL would
be the neatest solution. This way you just make one single "server" DLL
which
can be used by all your exe's, and all your plugin DLLs as well - can't see
anything wrong with that - alot easier to code and you don't have to play
games that the compiler+linker don't like very much :-)
cheers,
James
--
www.catch22.net
Free win32 software, sourcecode and tutorials
.
- References:
- Dynamic linking with symbols
- From: Philip Lawatsch
- Re: Dynamic linking with symbols
- From: James Brown
- Re: Dynamic linking with symbols
- From: Philip Lawatsch
- Dynamic linking with symbols
- Prev by Date: Memory mapped file API failed
- Next by Date: Re: Memory mapped file API failed
- Previous by thread: Re: Dynamic linking with symbols
- Next by thread: Re: Dynamic linking with symbols
- Index(es):
Relevant Pages
|