compiling a dll where the symbols are only defined at runtime

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

compiling a dll where the symbols are only defined at runtime

Carl-2-3
hi, i am a linux user, but i have interested in one of my projects
from the windows community, and now im trying to port everything to
windows.
in a nutshell, my project consists of a core program, and a bunch of
plugins, compiled as shared objects. Now under linux i compile the
core with the -rdynamic flag (im not even sure if this is neccesary)
and when i open the .so with dlopen all the symbols inside the core
program required by the .so are resolved. Im wondering if i can do the
same thing under windows, because when i try to compile the .dll i get
a list of every single core function as an linker error: undefined
symbol blah. So the only work around ive come up with so far is to
compile every single object into each of the plugins, making them each
5mb big, which is more or less unacceptable for my purposes. is there
a way to achieve the same effect that i do under linux, or am i going
to have to hack around this by compiling most of the core into a dll
and have each of the plugins and the core link to that.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compiling a dll where the symbols are only defined atruntime

Brian Dessent
Carl wrote:

> in a nutshell, my project consists of a core program, and a bunch of
> plugins, compiled as shared objects. Now under linux i compile the
> core with the -rdynamic flag (im not even sure if this is neccesary)
> and when i open the .so with dlopen all the symbols inside the core
> program required by the .so are resolved. Im wondering if i can do the
> same thing under windows, because when i try to compile the .dll i get
> a list of every single core function as an linker error: undefined
> symbol blah. So the only work around ive come up with so far is to
> compile every single object into each of the plugins, making them each
> 5mb big, which is more or less unacceptable for my purposes. is there
> a way to achieve the same effect that i do under linux, or am i going
> to have to hack around this by compiling most of the core into a dll
> and have each of the plugins and the core link to that.

Yes, it is certainly possible to create a plugin that accesses functions
and variables from the main executable.  But it doesn't work quite like
it does on ELF systems, and there are potential gotchas, so it requires
just a little bit of understanding of how PE/COFF works.

However, this topic comes up with some regularity and I feel like I've
written about it extensively already, so I'll just point you to several
past replies on the topic:

<http://thread.gmane.org/gmane.comp.gnu.mingw.user/27032/focus=27063>
<http://thread.gmane.org/gmane.comp.gnu.mingw.user/27513/focus=27515>
<http://thread.gmane.org/gmane.comp.gnu.mingw.user/17876/focus=17890>

If it still isn't clear how to proceed after reading through those
threads, then I'd be happy to elaborate.

Brian

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compiling a dll where the symbols are only defined atruntime

Carl-2-3
thank you, i spent a fair bit of time searching through gmane and
didnt find what i was looking for. i guess its just a case of picking
your key words.

On Sun, Nov 9, 2008 at 5:45 PM, Brian Dessent <[hidden email]> wrote:

> Carl wrote:
>
>> in a nutshell, my project consists of a core program, and a bunch of
>> plugins, compiled as shared objects. Now under linux i compile the
>> core with the -rdynamic flag (im not even sure if this is neccesary)
>> and when i open the .so with dlopen all the symbols inside the core
>> program required by the .so are resolved. Im wondering if i can do the
>> same thing under windows, because when i try to compile the .dll i get
>> a list of every single core function as an linker error: undefined
>> symbol blah. So the only work around ive come up with so far is to
>> compile every single object into each of the plugins, making them each
>> 5mb big, which is more or less unacceptable for my purposes. is there
>> a way to achieve the same effect that i do under linux, or am i going
>> to have to hack around this by compiling most of the core into a dll
>> and have each of the plugins and the core link to that.
>
> Yes, it is certainly possible to create a plugin that accesses functions
> and variables from the main executable.  But it doesn't work quite like
> it does on ELF systems, and there are potential gotchas, so it requires
> just a little bit of understanding of how PE/COFF works.
>
> However, this topic comes up with some regularity and I feel like I've
> written about it extensively already, so I'll just point you to several
> past replies on the topic:
>
> <http://thread.gmane.org/gmane.comp.gnu.mingw.user/27032/focus=27063>
> <http://thread.gmane.org/gmane.comp.gnu.mingw.user/27513/focus=27515>
> <http://thread.gmane.org/gmane.comp.gnu.mingw.user/17876/focus=17890>
>
> If it still isn't clear how to proceed after reading through those
> threads, then I'd be happy to elaborate.
>
> Brian
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compiling a dll where the symbols are only defined atruntime

Ralf Wildenhues
In reply to this post by Brian Dessent
Hello Brian,

* Brian Dessent wrote on Sun, Nov 09, 2008 at 07:45:14AM CET:
> However, this topic comes up with some regularity and I feel like I've
> written about it extensively already, so I'll just point you to several
> past replies on the topic:
>
> <http://thread.gmane.org/gmane.comp.gnu.mingw.user/27032/focus=27063>
> <http://thread.gmane.org/gmane.comp.gnu.mingw.user/27513/focus=27515>
> <http://thread.gmane.org/gmane.comp.gnu.mingw.user/17876/focus=17890>

Time for a FAQ/wiki entry?  Just a thought.

Cheers,
Ralf

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users