Program does not link to library even adding content of "pkg-config --libs" to $CFLAGS or $LDFLAGS

StackOverflow https://stackoverflow.com/questions/13999273

سؤال

I am trying to compile a program which depends upon GLib's libgthread. The library is installed in my machine (Ubuntu 12.04) and pkg-config finds it:

$ pkg-config --libs gthread-2.0
-pthread -lgthread-2.0 -lrt -lglib-2.0

I tried to run configure setting $CFLAGS with such output:

$ CFLAGS=`pkg-config --libs gthread-2.0` ./configure

but it did not work:

$ make
[...]
gcc  -g -O2 -I/include -I/home/adam/fs//include -I/usr/include/libxml2  -pthread -lgthread-2.0 -lrt -lglib-2.0   -o ama [...] -lxml2
ama-ama.o: In function `main':
/home/adam/software/ama/src/ama.c:89: undefined reference to `g_thread_init'
collect2: ld returned 1 exit status
make[2]: ** [ama] Erro 1
make[2]: Saindo do diretório `/home/adam/software/ama/src'
make[1]: ** [all-recursive] Erro 1
make[1]: Saindo do diretório `/home/adam/software/ama'
make: ** [all] Erro 2

I tried to set $LDFLAGS, too:

$ LDFLAGS=`pkg-config --libs gthread-2.0` ./configure

and got the same error.

What should I do?

هل كانت مفيدة؟

المحلول

The correct variable to set is $LIBS:

$ LIBS=`pkg-config --libs gthread-2.0` ./configure
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top