digitalmars.D.learn - How to link in a lib on cmd line?
- Nick Sabalausky (2/2) Sep 07 2010 I've tried all sorts of stuff and looked all over, but I'm completely at...
- Nick Sabalausky (38/44) Sep 07 2010 And I don't mean "with C" or anything like that, just ordinary D.
- Jonathan M Davis (6/8) Sep 07 2010 Don't you just include it as one of the arguments, like all of the .d fi...
- Nick Sabalausky (27/45) Sep 07 2010 ------------------------
- Steven Schveighoffer (10/58) Sep 08 2010 dmd just does a pass through:
I've tried all sorts of stuff and looked all over, but I'm completely at a loss. How do I link in a static lib on the command line?
Sep 07 2010
"Nick Sabalausky" <a a.a> wrote in message news:i66oia$25s1$1 digitalmars.com...I've tried all sorts of stuff and looked all over, but I'm completely at a loss. How do I link in a static lib on the command line?And I don't mean "with C" or anything like that, just ordinary D.type main.dmodule main; import theLib; void main() { foo(); }type theLib.dmodule foo; import std.stdio; void foo() { writeln("In foo"); }dmd theLib.d -libdmd main.d -LtheLib.libOPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html OPTLINK : Warning 9: Unknown Option : NOITHELIB.LIB main.obj(main) Error 42: Symbol Undefined _D3foo12__ModuleInfoZ main.obj(main) Error 42: Symbol Undefined _D3foo3fooFZv --- errorlevel 2 Same results for "-LtheLib". I saw something about "-L-ltheLibNameHere" somewhere, but "-L-ltheLib.lib" gets me: OPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html OPTLINK : Warning 9: Unknown Option : LTHELIB.LIB main.obj(main) Error 42: Symbol Undefined _D3foo12__ModuleInfoZ main.obj(main) Error 42: Symbol Undefined _D3foo3fooFZv --- errorlevel 2 And with "-L-ltheLib" the message just says "LTHELIB" instead of "LTHELIB.LIB"
Sep 07 2010
On Tuesday 07 September 2010 18:23:59 Nick Sabalausky wrote:I've tried all sorts of stuff and looked all over, but I'm completely at a loss. How do I link in a static lib on the command line?Don't you just include it as one of the arguments, like all of the .d files? I don't know. I haven't had a need to link in static libs before, and I usually do the linking step myself with gcc so that I can get a static binary (since -L- static doesn't currently work with dmd). - Jonathan M Davis
Sep 07 2010
"Jonathan M Davis" <jmdavisprog gmail.com> wrote in message news:mailman.129.1283909879.858.digitalmars-d-learn puremagic.com...On Tuesday 07 September 2010 18:23:59 Nick Sabalausky wrote:------------------------I've tried all sorts of stuff and looked all over, but I'm completely at a loss. How do I link in a static lib on the command line?Don't you just include it as one of the arguments, like all of the .d files? I don't know. I haven't had a need to link in static libs before, and I usually do the linking step myself with gcc so that I can get a static binary (since -L- static doesn't currently work with dmd).type main.dmodule main; import theLib; void main() { foo(); }type theLib.dmodule theLib; import std.stdio; void foo() { writeln("In foo"); }type theLib.dimodule theLib; void foo();dmd theLib.d -lib move theLib.d hide-this-file-and-keep-it-out-of-the-way-theLib.d dmd main.d theLib.libOPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html theLib.lib Warning 140: Library probably needs FIXLIBmainIn foo ------------------------ Ok, so that works, but with a linker warning. However, that can't be used with rdmd, becuase rdmd will interpret "theLib.lib" as the name of the program to be run.
Sep 07 2010
On Tue, 07 Sep 2010 22:28:57 -0400, Nick Sabalausky <a a.a> wrote:"Jonathan M Davis" <jmdavisprog gmail.com> wrote in message news:mailman.129.1283909879.858.digitalmars-d-learn puremagic.com...dmd just does a pass through: -L<arg-to-pass-to-linker> I have no clue what optlink's cryptic syntax is, but on Linux, it would be something along the lines of: -L-Llibdir -L-lmylib To give you an idea. Now go find the command line syntax for optlink :) Also, you can try dmd -v to see what link line it calls normally, I'm sure it has some of those options in there. -SteveOn Tuesday 07 September 2010 18:23:59 Nick Sabalausky wrote:------------------------I've tried all sorts of stuff and looked all over, but I'm completely at a loss. How do I link in a static lib on the command line?Don't you just include it as one of the arguments, like all of the .d files? I don't know. I haven't had a need to link in static libs before, and I usually do the linking step myself with gcc so that I can get a static binary (since -L- static doesn't currently work with dmd).type main.dmodule main; import theLib; void main() { foo(); }type theLib.dmodule theLib; import std.stdio; void foo() { writeln("In foo"); }type theLib.dimodule theLib; void foo();dmd theLib.d -lib move theLib.d hide-this-file-and-keep-it-out-of-the-way-theLib.d dmd main.d theLib.libOPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html theLib.lib Warning 140: Library probably needs FIXLIBmainIn foo ------------------------ Ok, so that works, but with a linker warning. However, that can't be used with rdmd, becuase rdmd will interpret "theLib.lib" as the name of the program to be run.
Sep 08 2010