Question

I have an autotools-based library project that I recently tried to compile on Ubuntu 13.10. It's worked on past versions, but now when it tries to link my test harness, libtool is changing -lcurl to /usr/lib/x86_64-linux-gnu/libcurl.so. Why is it doing this? If I manually remove $(CURL_LIBS) from app_LDADD and replace with -lcurl, it links correctly.

Configure.ac:

PKG_CHECK_MODULES(CURL, libcurl >= 7.20)

tests/Makefile.am:

check_mylib_LDADD = ../lib/libmylib.la \
        $(top_srcdir)/dep/childproj/lib/libchildprj.la $(CURL_LIBS) $(XML_LIBS) \
        $(SSL_LIBS)

Output from make. Note how -lcurl gets expanded to the .so file.

/bin/bash ../libtool  --tag=CC   --mode=link gcc -I/usr/include/libxml2 \
-I../dep/childproj/lib -I./../lib -I../dep/childproj/lib -g -O2 \
-Wall -Werror   -o check_mylib check_mylib-seatest.o check_mylib-test.o \
check_mylib-test_mylib.o check_mylib-test_xmlbind.o ../lib/libmylib.la  \
../dep/childproj/lib/libchildproj.la -lcurl   -lxml2   -lssl -lcrypto   

libtool: link: gcc -I/usr/include/libxml2 -I../dep/childproj/lib \
-I./../lib -I../dep/childproj/lib -g -O2 -Wall -Werror -o .libs/check_mylib \
check_mylib-seatest.o check_mylib-test.o check_mylib-test_mylib.o \
check_mylib-test_xmlbind.o  ../lib/.libs/libmylib.so  \
../dep/childproj/lib/.libs/libchildproj.so \
/usr/lib/x86_64-linux-gnu/libcurl.so -lxml2 -lssl -lcrypto -pthread

../dep/childproj/lib/.libs/libchildproj.so: undefined reference to `curl_easy_perform'
<more undefined reference errors>
Was it helpful?

Solution

According to the error message, libchildproj.so needs to be linked to libcurl. libchildproj.so is linked like:

/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -Wall -Werror \
-version-info 0:0:0 -o libchildproj.la -rpath /usr/local/lib \
object.lo rest_client.lo -L/usr/lib/x86_64-linux-gnu -lcurl

libtool: link: gcc -shared -fPIC -DPIC .libs/object.o .libs/rest_client.o \
-L/usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libchildproj.so -O2 \
-pthread -Wl,-soname -Wl,libchildproj.so.0 -o .libs/libchildproj.so.0.0.0

So in the actual link step (the last one) -lcurl isn't present, and wasn't linked to libchildproj.so. Adding $(CURL_LIBS) to libchildproj_la_LDADD fixed the link error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top