Re: Dynamic linking with symbols
- From: "James Brown" <remove_james_dot_brown7_at_virgin_dot_net>
- Date: Tue, 30 Aug 2005 17:37:38 +0100
"Philip Lawatsch" <philip@xxxxxxx> wrote in message
news:4gceu2x2nc.ln2@xxxxxxxxxx
> Hi,
>
>
> I've got a special problem:
>
> 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.
>
> This way I could use the plugin dll in both executables.
>
> I'd however like to avoid bringing yet another dll into the game and thus
> am looking for a unix like solution. On Linux for instance I can simply
> export the symbols of my executable by name and the dynamic loader will
> link the shared lib against the executable (it will happily link against
> any executable as long as the symbols are there) at runtime.
>
>
> Is there anything like this available on Windows?
>
>
> kind regards Philip
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.
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).
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.
James
--
www.catch22.net
Free win32 software, sourcecode and tutorials
.
- Follow-Ups:
- Re: Dynamic linking with symbols
- From: Philip Lawatsch
- Re: Dynamic linking with symbols
- References:
- Dynamic linking with symbols
- From: Philip Lawatsch
- Dynamic linking with symbols
- Prev by Date: Dynamic linking with symbols
- Next by Date: Re: Single instance DLL
- Previous by thread: Dynamic linking with symbols
- Next by thread: Re: Dynamic linking with symbols
- Index(es):
Relevant Pages
|