D issues are now
tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Summary: |
Installed libraries need to be passed in different order |
Product: |
D
|
Reporter: |
Lars Ivar Igesund <larsivar> |
Component: |
dmd | Assignee: |
Walter Bright <bugzilla> |
Status: |
RESOLVED
FIXED
|
Severity: |
normal
|
Priority: |
P2
|
Version: |
D1 (retired) |
Hardware: |
Other |
OS: |
Linux |
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.
Comment 1
Walter Bright
2007年04月20日 13:22:01 UTC
Fixed DMD 1.013