[Issue 15574] wrong order of linker arguments

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 15 13:04:07 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=15574

Remi Thebault <remi.thebault at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |remi.thebault at gmail.com

--- Comment #4 from Remi Thebault <remi.thebault at gmail.com> ---
Here is a simple test case to reproduce what is decribed by John:

 $ git clone https://github.com/rtbo/dmd_link_args_order
 $ cd dmd_link_args_order
 $ make app

It builds a static lib with C code, a static lib with D code that calls a C
function (bindings to the C code) and an D app that uses the D code.

 $ dmd -ofapp app.d libdsquare.a -L-L. -L-lcsquare

issues the following linker command:

 $ cc app.o -o app -m64 -L. -lcsquare -L/usr/lib -Xlinker --export-dynamic
libdsquare.a -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt
-ldl

Note that libdsquare.a is after -lcsquare and causes a link error.

An intermediate fix would be to place the *.a files before the linker switches
given on the command line.
I argue that *.a have much more chances to depend on -l libraries than the
opposite. This is what LDC is doing.

--


More information about the Digitalmars-d-bugs mailing list