Discussion:
Issue with AC_LANG_PROGRAM
Miguel Guedes
2013-07-18 09:36:16 UTC
Permalink
Hello,


I am using AC_LANG_PROGRAM to test for libboost_system and it invokes
gcc/g++ in the following way:

configure:3975: g++ -o conftest -g -O2 -lboost_system conftest.cpp

The above results in a few errors and doesn't link even though the
library in question is present in the system. This is because the
source file should be at the front in the call to g++, e.g.:

g++ conftest.cpp -o conftest -g -O2 -lboost_system

What can be done with autoconf to overcome this limitation? Can the
parameter order be customized somehow or perhaps some other macro be used?


Miguel
Eric Blake
2013-07-18 12:08:27 UTC
Permalink
Post by Miguel Guedes
Hello,
I am using AC_LANG_PROGRAM to test for libboost_system and it invokes
configure:3975: g++ -o conftest -g -O2 -lboost_system conftest.cpp
The above results in a few errors and doesn't link even though the
library in question is present in the system. This is because the
g++ conftest.cpp -o conftest -g -O2 -lboost_system
That's probably because you put -lboost_system into LDFLAGS instead of
the proper LIBS (LDFLAGS is for -L/path, LIBS for -llib).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Earnie Boyd
2013-07-18 12:20:44 UTC
Permalink
Post by Eric Blake
Post by Miguel Guedes
Hello,
I am using AC_LANG_PROGRAM to test for libboost_system and it invokes
configure:3975: g++ -o conftest -g -O2 -lboost_system conftest.cpp
The above results in a few errors and doesn't link even though the
library in question is present in the system. This is because the
g++ conftest.cpp -o conftest -g -O2 -lboost_system
That's probably because you put -lboost_system into LDFLAGS instead of
the proper LIBS (LDFLAGS is for -L/path, LIBS for -llib).
That answer is still problematic since I need -L/path to instruct
where to find my -llib. I.E. LDFLAGS value need to be specified before
LIB value for the test.
--
Earnie
-- https://sites.google.com/site/earnieboyd
Eric Blake
2013-07-18 12:26:26 UTC
Permalink
Post by Earnie Boyd
Post by Eric Blake
Post by Miguel Guedes
Hello,
I am using AC_LANG_PROGRAM to test for libboost_system and it invokes
configure:3975: g++ -o conftest -g -O2 -lboost_system conftest.cpp
The above results in a few errors and doesn't link even though the
library in question is present in the system. This is because the
g++ conftest.cpp -o conftest -g -O2 -lboost_system
That's probably because you put -lboost_system into LDFLAGS instead of
the proper LIBS (LDFLAGS is for -L/path, LIBS for -llib).
That answer is still problematic since I need -L/path to instruct
where to find my -llib. I.E. LDFLAGS value need to be specified before
LIB value for the test.
AC_LANG_PROGRAM tests (roughly):
$CC -o conftest $CFLAGS $LDFLAGS conftest.cpp $LIBS

which does precisely what you want, if you stick -L in LDFLAGS and -l in
LIBS.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Miguel Guedes
2013-07-18 13:21:00 UTC
Permalink
Post by Eric Blake
That's probably because you put -lboost_system into LDFLAGS instead of
the proper LIBS (LDFLAGS is for -L/path, LIBS for -llib).
I was actually unaware of the LIBS variable and was using only LDFLAGS
for both specifying library paths and libraries.

As a side note, apologies, Eric and List, for my duplicate queries
(duplicate is 'Invocation of compiler by AC_LINK_IFELSE'). I'd sent my
original query to ***@gnu.org (as per instructed on the autoconf
page on the GNU website) but thought it hadn't gone through as lately
I've been having internet connectivity issues; and so after slightly
reworking my original email I re-posted via Gmane.

Again, apologies and many thanks to all who've contributed enlightenment!
Loading...