[phobos] 32 and 64 bit libraries on Linux
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jan 4 14:53:31 PST 2011
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
More information about the phobos
mailing list