On 12/8/2013 6:12 AM, Mafi wrote:
On Friday, 6 December 2013 at 16:54:14 UTC, Jacob Carlborg wrote:
I would say that linking order shouldn't matter. But for some reason
it does. This not really my area of expertise but I know that others
have had the same problem. You can try and search the newsgroups for
linking order related problems.
So after some tweaking I made it work. Specfying the libpath with -L-L
and the actual -L-l invokes gcc correctly. But the other behavior is
still odd for me. I mean invoking dmd with
dmd myprog.d /path/to/libSomething.a -L[Linkerflags]
links with
gcc myprog.o [Linkerflags] /path/to/libSomething.a [Phobos]
you must
dmd myprog.d -L-L/path/to/ -l-lSomething
and hope the file name has the format libName.a .
But why? Both are objects. Why seperate them? For me there is no reason
to ever want this order!
This is how the gcc linker works. It always causes confusion when people
first encounter it. And even for people who have experience with it,
there are corner cases where it's not always obvious that link order was
the cause of an error. Google for "gcc link order" and you'll likely
find some useful reading somewhere.