DMD2 - compiling and linking in separate steps (64-bit)

Jason E. Aten j.e.aten at gmail.com
Mon Mar 21 07:38:53 PDT 2011


On Sat, 19 Mar 2011 13:52:05 +0000, Sean Eskapp wrote:

> == Quote from Jonathan M Davis (jmdavisProg at gmx.com)'s article
>> On Friday 18 March 2011 20:49:58 Sean Eskapp wrote:
>> > incompatible /usr/lib/../lib/librt.so when searching for -lrt
>> > /usr/bin/ld: skipping incompatible /usr/lib/../lib/librt.a when
>> > searching for -lrt
>> > /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-
>> > gnu/4.4.5/../../../librt.so when searching for -lrt /usr/bin/ld:
>> > skipping incompatible /usr/lib/gcc/x86_64-linux-
>> > gnu/4.4.5/../../../librt.a when searching for -lrt /usr/bin/ld:
>> > skipping incompatible /usr/lib/gcc/x86_64-linux-
>> > gnu/4.4.5/../../../../lib/libc.so
>> Look at dmd.conf. It includes several flags which are supposed to be
>> passed to the linker - either that or you can use dmd to link rather
>> than using gcc on its own. Personally, I wouldn't bother compiling and
>> linking as separate steps, but if you do, you need to make sure that
>> you either use the flags in dmd.conf or you link with dmd rather than
>> gcc. For the most part, there's no reason to link with gcc, even if you
>> want to link separately. - Jonathan M Davis
> 
> Hmm.. after linking with all the options in dmd.conf (-L/usr/lib32
> -L/usr/lib64 --no-warn-search-mismatch --export-dynamic -lrt), I still
> get
> 
> /usr/bin/ld: skipping incompatible
> /home/me/devl/sfml2/bindings/d/lib/libdsfml-system.a when searching for
> -ldsfml-system /usr/bin/ld: cannot find -ldsfml-system /usr/bin/ld:
> skipping incompatible
> /home/me/devl/sfml2/bindings/d/lib/libdsfml-graphics.a when searching
> for -ldsfml-graphics /usr/bin/ld: cannot find -ldsfml-graphics
> /usr/bin/ld: skipping incompatible
> /home/me/devl/sfml2/bindings/d/lib/libdsfml-audio.a when searching for
> -ldsfml-audio /usr/bin/ld: cannot find -ldsfml-audio /usr/bin/ld:
> skipping incompatible
> /home/me/devl/sfml2/bindings/d/lib/libdsfml-window.a when searching for
> -ldsfml-window /usr/bin/ld: cannot find -ldsfml-window collect2: ld
> returned 1 exit status
> 
> Now, I compiled libdsfml-system.a myself, and I know they're 64-bit, so
> this implies ld still isn't recognizing that I want 64-bit executables.

I think the reason that ld is skipping those libraries is that secretly, 
inside the .a archives, they are really 32-bit libraries and not 64-bit 
libraries.

You can confirm this by using the "ar x {somelibrary}.z" to extract the 
object files (do it from a new temp directory), and then running "file 
{new}.o", which in my hands reports that the dmd libraries such as phobos 
are actually 32-bit, even on x86_64 linux.

This is why I went to LDC2, which is fully 64-bit.

- Jason


More information about the Digitalmars-d-learn mailing list