On Tue, 07 Sep 2010 22:28:57 -0400, Nick Sabalausky <[email protected]> wrote:

"Jonathan M Davis" <[email protected]> wrote in message
news:[email protected]...
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.d
module main;
import theLib;
void main()
{
    foo();
}

type theLib.d
module theLib;
import std.stdio;
void foo()
{
    writeln("In foo");
}

type theLib.di
module 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.lib

OPTLINK (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 FIXLIB

main
In 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.

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.

-Steve

Reply via email to