From: Marc V. <vai...@fa...> - 2009-01-28 03:36:10
|
On Wed, Jan 28, 2009 at 12:09:03PM +1100, Carl wrote: > On Wed, Jan 28, 2009 at 10:12 AM, Marc Vaillant <vai...@fa...> wrote: > > > > > > On Jan 27, 2009, at 10:38, Carl <car...@gm...> wrote: > > > >> Hi, I am developing a GPL program for linux which id like to port to > >> windows. The linux version has a core binary, and plugins compiled > >> into .so's which link to many of the functions within the core binary. > >> Because of the magic of ld, everything works. Under windows I had a > >> problem that I couldn't work out a way to link the .dll's to the main > >> .exe without making a serious mess. > > > > What magic are u referring to? What's different abt windows dlls that > > did not let u do what u were doing on linux? > > > > Marc > > > A lot it seems. The most important difference is that a .dll must have > all references defined at run time, whilst a .so does not. when a .so > is loaded ld will resolve all dependencies of the .so at run time, a > .dll must know where to look for its dependencies at run time. This is > especially important when using c++, it would be an absolute pain to > export/import a class manually, with member functions and vtable etc. I'm sorry I don't quite understand what you are trying to say here? Attached is an example of a client program which depends on a dll libInterface.dll, and this dll depends on another called libBackend.dll. The client program and the dlls compile and are linked exactly the same way for my OS X g++ + ld as with my mingw-g++ + ld. Can you modify to illustrate what you mean? mingw: $ i386-mingw32-g++ -o libBackend.dll Backend.cpp -shared $ i386-mingw32-g++ -o libInterface.dll Interface.cpp -shared $ i386-mingw32-g++ -o client.exe client.cpp -lInterface -L. $ wine client.exe called interface member func called backend member func osx: $ g++ -o libBackend.dylib Backend.cpp -dynamiclib $ g++ -o libInterface.dylib Interface.cpp -dynamiclib -lBackend -L. $ g++ -o client client.cpp -lInterface -L. $ ./client called interface member func called backend member func |