|
From: Stefan B. <sb...@sb...> - 2005-10-30 10:34:25
|
Tor Lillqvist wrote: > > 2) On GNU/Linux, I have one project where one shared object refers > > back to symbols of the main application. [...] Now, when trying to > > build the same on Windows (using gcc -shared as well), the DLL > > doesn't even build but throws errors of "undefined references". I > > want those to get resolved when linking against the main > > application. Is such a set-up not possible on Windows? > It is possible, but it is not as flexible as on ELF-based systems like > Linux. Firstly, you must mark the function in the main .exe that you > want to access from a DLL for export using > __declspec(dllexport). Then, there are two possibilities how to > actually access the functions from the DLL: > 1) you can create an import library for the foo.exe using a foo.def > file like this: [snip] > dlltool --input-def foo.def --output-lib libfoo.a --dllname > foo.exe > Then link the DLL with libfoo.a. Ok, I see. However, this doesn't work if the foo.exe itself depends on the DLL. So, circular dependencies are impossible, correct? > 2) Look up the symbol at runtime. Read up on GetProcAddress() and > GetModuleHandle(). And how would I link the DLL itself using this second approach? -- Stefan Bellon |