1

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?

1 Answer 1

1

The correct variable to set is $LIBS:

$ LIBS=`pkg-config --libs gthread-2.0` ./configure
Sign up to request clarification or add additional context in comments.

2 Comments

With modern autoconf, it is generally preferred to do ./configure LIBS=$( pkg-config --libs gthread-2.0 ), passing the assignment of LIBS as an argument to configure rather than setting it in the environment.
@WilliamPursell this seems much more reasonable to me but I did not know it. Thank you! It was worth to post this question only for this discovery.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.