[Issue 1156] New: Installed libraries need to be passed in different order
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 17 09:20:13 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1156
Summary: Installed libraries need to be passed in different order
Product: D
Version: 1.012
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: larsivar at igesund.net
DMD don't understand how to order libraries on Linux. In short, ld (and gcc
which DMD use for linking) needs that libraries are passed in dependency order.
That is, if library A depends on library B, then the linker needs that A is
passed before B. Since all D libraries depends on libphobos, they must be
passed before phobos on the command line. This works as it should if you pass
the library with full name and path, for instance
dmd mysource.d libmylib.a
This also works if libmylib.a is put in dmd.conf/DFLAGS with the full path.
However, if a library is installed in for instance /usr/lib or /usr/local/lib,
gcc will find it if it is given the command -lmylib. Passing this via DMD,
using the -L switch (like -L-lmylib ) will not work, because these are added at
the end of the gcc commandline, that is after libphobos which it depends on.
Thus DMD should always pass additional arguments to the linker before libphobos
on the argument line. An additional thing one could do, was to check if -L is
followed by -l, in which case -Xlinker isn't needed.
--
More information about the Digitalmars-d-bugs
mailing list