www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1156] New: Installed libraries need to be passed in different order

reply d-bugmail puremagic.com writes:

           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 digitalmars.com
        ReportedBy: larsivar 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.

Apr 17 2007
parent d-bugmail puremagic.com writes:

bugzilla digitalmars.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

------- Comment #1 from bugzilla digitalmars.com  2007-04-20 13:22 -------
Fixed DMD 1.013

Apr 20 2007