Thread overview
Making a DLL with a static library dependency
Dec 15, 2009
Phil Deets
Dec 15, 2009
Phil Deets
Dec 15, 2009
Trass3r
Dec 15, 2009
Phil Deets
Dec 15, 2009
Kagamin
Dec 17, 2009
Phil Deets
Dec 17, 2009
Phil Deets
December 15, 2009
(D 2.033) I'm porting a DLL to D. The DLL depends on a static library, but when I put the library name on the command-line, dmd does not output any DLL file. If I remove the library name from the command-line, dmd gives linker errors and outputs an invalid DLL. How do I make a DLL with a static library dependency?
December 15, 2009
On Tue, 15 Dec 2009 00:56:12 -0500, Phil Deets <pjdeets2@gmail.com> wrote:

> (D 2.033) I'm porting a DLL to D. The DLL depends on a static library, but when I put the library name on the command-line, dmd does not output any DLL file. If I remove the library name from the command-line, dmd gives linker errors and outputs an invalid DLL. How do I make a DLL with a static library dependency?

Actually, it depends on another DLL. The static library I need to link to is an import library for that DLL. I'll work on loading that DLL without the .lib file using the Windows API while I wait for an answer here.
December 15, 2009
Phil Deets schrieb:
> Actually, it depends on another DLL. The static library I need to link to is an import library for that DLL. I'll work on loading that DLL without the .lib file using the Windows API while I wait for an answer here.

I'm not sure if the Windows loader does such chained DLL loading.
But you can always use LoadLibrary & GetProcAddress for that purpose.
December 15, 2009
On Tue, 15 Dec 2009 07:06:49 -0500, Trass3r <mrmocool@gmx.de> wrote:

> Phil Deets schrieb:
>> Actually, it depends on another DLL. The static library I need to link to is an import library for that DLL. I'll work on loading that DLL without the .lib file using the Windows API while I wait for an answer here.
>
> I'm not sure if the Windows loader does such chained DLL loading.
> But you can always use LoadLibrary & GetProcAddress for that purpose.

It worked fine in C++.
December 15, 2009
Trass3r Wrote:

> I'm not sure if the Windows loader does such chained DLL loading. But you can always use LoadLibrary & GetProcAddress for that purpose.

Well... dll that can't call any function from kernel32.dll is practically useless.
December 17, 2009
On Tue, 15 Dec 2009 00:56:12 -0500, Phil Deets <pjdeets2@gmail.com> wrote:

> (D 2.033) I'm porting a DLL to D. The DLL depends on a static library, but when I put the library name on the command-line, dmd does not output any DLL file. If I remove the library name from the command-line, dmd gives linker errors and outputs an invalid DLL. How do I make a DLL with a static library dependency?

(now using D 2.037) I used optlink separately from dmd to see whether the problem is in dmd or optlink. It turns out to be an optlink issue. Everything works fine when I link in phobos.lib and kernel32.lib, but as soon as I link in lua51.lib there is no dll output. Could this be because I compiled lua51.dll/.lib with Visual Studio? I'll try compiling Lua with dmc.
December 17, 2009
On Thu, 17 Dec 2009 08:32:41 -0500, Phil Deets <pjdeets2@gmail.com> wrote:

> On Tue, 15 Dec 2009 00:56:12 -0500, Phil Deets <pjdeets2@gmail.com> wrote:
>
>> (D 2.033) I'm porting a DLL to D. The DLL depends on a static library, but when I put the library name on the command-line, dmd does not output any DLL file. If I remove the library name from the command-line, dmd gives linker errors and outputs an invalid DLL. How do I make a DLL with a static library dependency?
>
> (now using D 2.037) I used optlink separately from dmd to see whether the problem is in dmd or optlink. It turns out to be an optlink issue. Everything works fine when I link in phobos.lib and kernel32.lib, but as soon as I link in lua51.lib there is no dll output. Could this be because I compiled lua51.dll/.lib with Visual Studio? I'll try compiling Lua with dmc.

I fixed the problem by using implib on lua51.dll to generate a new .lib file. The DLL isn't working properly, but this is likely a different issue; so I'll open a new thread for that if necessary.