[phobos] 32 and 64 bit libraries on Linux

Walter Bright walter at digitalmars.com
Tue Jan 4 15:18:16 PST 2011


The command and the barf:

gcc foo.o -o foo -m32 -Xlinker -L/home/walter/cbx/mars1/phobos -lphobos 
-lpthread -lm
/usr/bin/ld: skipping incompatible 
/home/walter/cbx/mars1/phobos/libphobos.a when searching for -lphobos
/usr/bin/ld: cannot find -lphobos
collect2: ld returned 1 exit status
--- errorlevel 1


So, what to do?

1. what to name the libraries?
2. where to put the libraries?
3. how should dmd invoke gcc to do the linking?
4. what goes in dmd.conf?

1,2,3 for -m32, -m64, and the default?

Jonathan M Davis wrote:
> On Tuesday, January 04, 2011 11:59:46 Walter Bright wrote:
>   
>> So, is this what happens:
>>
>>     gcc    => looks in /usr/lib
>>     gcc -m32     => looks in /usr/lib32
>>     gcc -m64    => looks in /usr/lib64
>>
>> ?
>>     
>
> No. It's definitely smart enough to figure out whether libraries are 64 bit or not 
> and deal with it. I believe that it looks in /lib, /usr/lib, and /usr/local/lib 
> by default, but it also looks in the directories listed in /etc/ld.so.conf. On 
> my 64-bit SuSE box, ld.so.conf contains:
>
> /usr/X11R6/lib64/Xaw3d
> /usr/X11R6/lib64
> /usr/lib64/Xaw3d
> /usr/X11R6/lib/Xaw3d
> /usr/X11R6/lib
> /usr/lib/Xaw3d
> /usr/x86_64-suse-linux/lib
> /usr/local/lib
> /opt/kde3/lib
> /lib64
> /lib
> /usr/lib64
> /usr/lib
> /usr/local/lib64
> /opt/kde3/lib64
> include /etc/ld.so.conf.d/*.conf
>
> Notice that the 64-bit and 32-bit library directories are completely mixed. ld 
> is somehow able to determine whether a library is 32-bit or 64-bit and use the 
> correct one. And while it does list /lib, /usr/lib, and /usr/local/lib in that 
> ld.so.conf, the one of my 32-bit Arch box doesn't have any, so it's obviously 
> able to find at least /lib and /usr/lib without an ld.so.conf.
>
> So, why you were finding that gcc was barfing on the wrong library type, I don't 
> know. Maybe you gave it to it directly or something, rather then letting it find 
> it. But gcc can definitely find the correct library without understanding which 
> directories hold which types of libraries.
>
> - Jonathan M Davis
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>
>   


More information about the phobos mailing list