Solved Linker error

sprock

Member

Reaction score: 4
Messages: 61

Hello,

I'm trying to compile some test code like this: cc -Wall -g -o tutorial main.c `pkg-config --cflags --libs gtk+-2.0` -export-dynamic but the linker complains:
Code:
/usr/bin/ld: cannot find -lintl
libintl exists and is found by ldconfig -r. This follows having run pkg delete -f gettext and pkg upgrade as per the most recent /usr/ports/UPDATING file.

Thanks for any suggestions.

sprock
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,409
Messages: 29,985

You probably need to add:
Code:
-L/usr/local/lib -I/usr/local/include
They're not included by default.
 

fonz

Son of Beastie

Reaction score: 369
Messages: 2,560

You probably need to add:
Code:
-L/usr/local/lib -I/usr/local/include
They're not included by default.
The pkg-config thing should add all the right -I, -l and -L flags.
 
OP
OP
S

sprock

Member

Reaction score: 4
Messages: 61

The pkg-config thing should add all the right -I, -l and -L flags.
Indeed. I fixed (really, worked around) the problem by using the output of pkg-config but removing the call to -lintl.

Thanks to both of you for your help.

sprock
 

fonz

Son of Beastie

Reaction score: 369
Messages: 2,560

Do keep in mind that it's exactly what you called it: a workaround, not a real fix. It shouldn't be necessary.
 
OP
OP
S

sprock

Member

Reaction score: 4
Messages: 61

I made a symlink from libintl.so to libintl.so.8.1.2 in /usr/local/lib. Using -lintl as part of the compiler invocation then works.

Looking in /usr/ports/devel/gettext-runtime the pkg-plist shows libintl.so.9 and libintl.so in addition to the libintl.so.8 and libintl.so.8.1.2 that were installed using the binary package in the repository. Thus, building the port seems to be the best fix.

Thanks again.

sprock
 
Top