Thread overview
Problem with compiling static libraries
Jun 30, 2013
Mike Parker
Jul 02, 2013
Kai Nacke
Jul 03, 2013
Mike Parker
June 30, 2013
I've finally been playing around with LDC on Windows and I love it so far. But I've run into something rather frustrating and I don't know if it's a bug or by design.

I'm using the MinGW backed version. The problem is that when I compile a static library, LDC decides to automatically prepends 'lib' and appends '.lib' to the output. That was really unexpected. It breaks the build script I have for Derelict, which handles library name formatting based on platform and also drops all the libraries into a lib directory. DMD and GDC do the right thing, but given this command:

-ofC:\lib\libFoo.a

The compiler errors out because it's truing to find libC:\lib\libFoo.a.lib.

I've been scrolling through compiler options and can't find anything that allows me to set the output directory for the binary. -od handles object files well enough, but doesn't put the library there.

Have I overlooked something? Is there a way to specify the output directory for the binary?
July 02, 2013
On Sunday, 30 June 2013 at 13:57:28 UTC, Mike Parker wrote:
> I've finally been playing around with LDC on Windows and I love it so far. But I've run into something rather frustrating and I don't know if it's a bug or by design.
>
> I'm using the MinGW backed version. The problem is that when I compile a static library, LDC decides to automatically prepends 'lib' and appends '.lib' to the output. That was really unexpected. It breaks the build script I have for Derelict, which handles library name formatting based on platform and also drops all the libraries into a lib directory. DMD and GDC do the right thing, but given this command:
>
> -ofC:\lib\libFoo.a
>
> The compiler errors out because it's truing to find libC:\lib\libFoo.a.lib.
>
> I've been scrolling through compiler options and can't find anything that allows me to set the output directory for the binary. -od handles object files well enough, but doesn't put the library there.
>
> Have I overlooked something? Is there a way to specify the output directory for the binary?

Hi Mike!

Does the MingW tool chain use .a for static libs, too? Then the initialization of global.lib_ext is wrong. (It currently uses ".lib" for all Windows targets.)

Kai
July 03, 2013
On Tuesday, 2 July 2013 at 20:02:59 UTC, Kai Nacke wrote:

> Hi Mike!
>
> Does the MingW tool chain use .a for static libs, too? Then the initialization of global.lib_ext is wrong. (It currently uses ".lib" for all Windows targets.)
>
> Kai

Yes, it uses .a for static libs, but .dll for shared libs.

However, the issue for me is that the compiler automatically adds a prefix and suffix to the lib name in the first place. I'd either like to turn it off, or have a way to specify a path for the library to be output to. Currently, specifying something like "-ofC:/path/to/mylib" results in "libC:/path/to/mylib.lib".