lvella
lvella

Reputation: 13413

GCC linker doesn't find 32-bit library on a 64-bit system when using -L/-l?

In a 64 bits systems, it fails if I try to compile a configure test with:

$ gcc -m32 -o conftest -L/usr/lib/i386-linux-gnu/ conftest.c -lfreetype
/usr/bin/ld: cannot find -lfreetype
collect2: ld returned 1 exit status

but it is successful if I do:

$ gcc -m32 -o conftest conftest.c /usr/lib/i386-linux-gnu/libfreetype.so.6

Why can't ld find 32bit libfreetype.so.6 in the first case?

Upvotes: 1

Views: 4127

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753455

There's a difference between the runtime and development system. The linker is looking for libfreetype.so and is not finding it. The program at runtime is looking for libfreetype.so.6 and finds it.

You should install the FreeType development package.

Before going to that much effort, though, you can validate this hypothesis by first checking that libfreetype.so does not exist in /usr/lib/i386-linux-gnu, and then by using root privileges to do:

cd /usr/lib/i386-linux-gnu
ln -s libfreetype.so.6 libfreetype.so

and then retrying the first command line.

If that works, then remove the symlink just created and then install the FreeType development package.

Upvotes: 3

Related Questions