Problems linking libdl?

Mike Wey mike-wey at example.com
Tue Feb 21 10:44:24 PST 2012


On 02/20/2012 10:33 PM, simendsjo wrote:
> On Mon, 20 Feb 2012 22:26:58 +0100, Mike Wey <mike-wey at example.com> wrote:
>
>> On 02/20/2012 09:49 PM, simendsjo wrote:
>>> On Mon, 20 Feb 2012 21:41:45 +0100, simendsjo <simendsjo at gmail.com>
>>> wrote:
>>>
>>>>
>>>> I've tried the following using dmd 58 and trunk - both -m64 on kubuntu.
>>>> Any idea what I'm doing wrong?
>>>>
>>>> import std.loader;
>>>> void main(string[] args)
>>>> {
>>>> auto res = ExeModule_Init();
>>>> assert(res == 0);
>>>> scope(exit) ExeModule_Uninit();
>>>> auto mod = ExeModule_Load("./libtcod.so");
>>>> }
>>>>
>>>> $ dmd-trunk -v -L-ldl so.d
>>>>
>>>> gcc so.o -o so -m64 -ldl -Xlinker
>>>> -L/home/simendsjo/code/dmd-trunk/build/lib64 -Xlinker
>>>> -L/home/simendsjo/code/dmd-trunk/build/lib -Xlinker
>>>> --no-warn-search-mismatch -Xlinker --export-dynamic -lphobos2
>>>> -lpthread -lm -lrt
>>> ....
>>> I get the same error using gdc-4.6
>>
>> The problem is that -ldl should appear after -lphobos2 in the
>> arguments passed to gcc.
>>
>
> Ok, that removed the error (although I got another).
> But how can I specify this when I run dmd or gdc? dmd and gdc adds -L
> options before phobos...

The last time this problem came up in the newsgroup, with librt, it was 
moved from the configuration file into the compiler, so now it's hardcoded.

You could try passing -L--start-group before -L-ldl it should cause ld 
to recursively search for the symbols.

Unfortunately i can't test this on my system.

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list