Unresolvable references to dlopen, dlclose etc

Mafi mafi at example.org
Sat Dec 7 13:12:06 PST 2013


On Friday, 6 December 2013 at 16:54:14 UTC, Jacob Carlborg wrote:
> On 2013-12-06 14:25, Mafi wrote:
>
>> Thank you! This has helped and I linked my program. As it 
>> turned out dmd
>> invoked gcc to link and it supplied my -ldl argument first! I
>> copy-pasted that command into a shell and moved the -ldl to 
>> the very end
>> and it worked.
>>
>> How do instruct dmd to do the same? As far as I understand the 
>> problem
>> is that I specified the full path to the Derelict lib files by 
>> hand for
>> each lib instead of using -L and -l. Libraries specifed like 
>> that are
>> put after the gilen linker flags and before the buitlin ones 
>> (-lphobos
>> etc). Is this a bug or is there any reason for dmd's behavior? 
>> It seems
>> very wrong to me.
>
> 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!


More information about the Digitalmars-d-learn mailing list