www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Making a DLL with a static library dependency

reply "Phil Deets" <pjdeets2 gmail.com> writes:
(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?
Dec 14 2009
next sibling parent reply "Phil Deets" <pjdeets2 gmail.com> writes:
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.
Dec 14 2009
parent reply Trass3r <mrmocool gmx.de> writes:
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.
Dec 15 2009
next sibling parent "Phil Deets" <pjdeets2 gmail.com> writes:
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++.
Dec 15 2009
prev sibling parent Kagamin <spam here.lot> writes:
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.
Dec 15 2009
prev sibling parent reply "Phil Deets" <pjdeets2 gmail.com> writes:
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.
Dec 17 2009
parent "Phil Deets" <pjdeets2 gmail.com> writes:
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.
Dec 17 2009