mapnik-org/mapnik — Issue #523: SCons CheckLibWithHeader should not use all libraries but actually target specific lib and header
Author: artemp
Created: 2011-10-11 08:00:17+00:00
State: open
Labels: Core_Library

This will be a big behavior change, so we'll need to carefully test (because previously adding e.g. the includes for ICU would allow boost to be found if in the same location, while boost includes could be wrong).

But, problems can break SCons scripts when libs are attached that are not the ones being tested and includes have not been properly added.

For example this was seen on CentOS 5.4 when checking for MAPNIK_VERSION:

{{{
g++ -o .sconf_temp/conftest_32.o -c -DHAVE_LIBXML2 -DHAVE_CAIRO -DHAVE_PYCAIRO -Iagg/include -I. -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/cairomm-1.0 -I/usr/include/cairo -I/usr/include/libpng12 -I/usr/include -I/usr/include/pycairo .sconf_temp/conftest_32.cpp
g++ -o .sconf_temp/conftest_32 .sconf_temp/conftest_32.o -Lagg -Lsrc -L/usr/lib64 -L/usr/local/lib64 -L/usr/local/lib -lfreetype -lxml2 -lcairomm-1.0 -lcairo -lm -lltdl -lpng -ltiff -lz -ljpeg -lproj -licuuc -lboost_system -lboost_filesystem -lboost_regex -lboost_iostreams -lboost_program_options -lboost_thread -lsqlite3 -lpq -lgdal
/usr/bin/ld: cannot find -lpq
}}}

fuller log show oddity because pg_config was found:
{{{
scons: Configure: Checking for pg_config...
pg_config
BINDIR = /usr/bin
DOCDIR = /usr/share/doc/pgsql
INCLUDEDIR = /usr/include
PKGINCLUDEDIR = /usr/include/pgsql
INCLUDEDIR-SERVER = /usr/include/pgsql/server
LIBDIR = /usr/lib64
PKGLIBDIR = /usr/lib64/pgsql
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/man
SHAREDIR = /usr/share/pgsql
SYSCONFDIR = /etc/sysconfig/pgsql
PGXS = /usr/lib64/pgsql/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-rpath' '--with-perl' '--with-tcl' '--with-tclconfig=/usr/lib64' '--with-python' '--with-openssl' '--with-pam' '--with-krb5' '--enable-nls' '--enable-thread-safety' '--sysconfdir=/etc/sysconfig/pgsql' '--datadir=/usr/share/pgsql' '--with-docdir=/usr/share/doc' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'target_alias=x86_64-redhat-linux-gnu'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv
CFLAGS_SL = -fpic
LDFLAGS =
LDFLAGS_SL =
LIBS = -lpgport -lpam -lssl -lcrypto -lkrb5 -lz -lreadline -ltermcap -lcrypt -lresolv -lnsl -ldl -lm -lbsd
VERSION = PostgreSQL 8.1.18
scons: Configure: yes

scons: Configure: Checking if gdal is ogr enabled...
gdal-config --ogr-enabled
yes
scons: Configure: yes

scons: Configure: Checking for name of ogr library...
gdal-config --libs
-L/usr/lib64 -lgdal
scons: Configure: gdal

scons: Configure: Checking for C++ library ociei...
.sconf_temp/conftest_24.cpp <-
|
|
|#include "occi.h"
|
|int
|main() {
|
|return 0;
|}
|
g++ -o .sconf_temp/conftest_24.o -c -DHAVE_LIBXML2 -DHAVE_CAIRO -I/usr/lib/oracle/10.2.0.3/client/include -I/usr/include -Iinclude -I. -I/usr/local/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/cairomm-1.0 -I/usr/include/cairo -I/usr/include/libpng12 -I/usr/include .sconf_temp/conftest_24.cpp
.sconf_temp/conftest_24.cpp:3:18: error: occi.h: No such file or directory
scons: Configure: no

scons: Configure: Checking for C library rasterlite...
.sconf_temp/conftest_25.c <-
|
|
|#include "sqlite3.h"
|#include "rasterlite.h"
|
|int
|main() {
|
|return 0;
|}
|
gcc -o .sconf_temp/conftest_25.o -c -I/usr/include -Iinclude -I. -I/usr/local/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/cairomm-1.0 -I/usr/include/cairo -I/usr/include/libpng12 .sconf_temp/conftest_25.c
.sconf_temp/conftest_25.c:4:24: error: rasterlite.h: No such file or directory
scons: Configure: no

scons: Configure: Checking for gdal-config --libs...
gdal-config --libs
-L/usr/lib64 -lgdal
scons: Configure: yes

scons: Configure: Checking for gdal-config --cflags...
gdal-config --cflags
-I/usr/include
scons: Configure: yes

scons: Configure: Checking for name of gdal library...
gdal-config --libs
-L/usr/lib64 -lgdal
scons: Configure: gdal

scons: Configure: Checking for C++ header file boost/python/detail/config.hpp...
.sconf_temp/conftest_29.cpp <-
|
|#include
|
|
g++ -o .sconf_temp/conftest_29.o -c -DHAVE_LIBXML2 -DHAVE_CAIRO -Iagg/include -I. -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/cairomm-1.0 -I/usr/include/cairo -I/usr/include/libpng12 -I/usr/include .sconf_temp/conftest_29.cpp
scons: Configure: yes

scons: Configure: Checking for pkg-config...
pkg-config --atleast-pkgconfig-version=0.15.0
scons: Configure: yes

scons: Configure: Checking for pycairo...
pkg-config --exists 'pycairo'
scons: Configure: yes

.sconf_temp/conftest_32.cpp <-
|
|
|#include
|#include
|
|int main()
|{
| std::cout << MAPNIK_VERSION << std::endl;
| return 0;
|}
|
|
g++ -o .sconf_temp/conftest_32.o -c -DHAVE_LIBXML2 -DHAVE_CAIRO -DHAVE_PYCAIRO -Iagg/include -I. -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/cairomm-1.0 -I/usr/include/cairo -I/usr/include/libpng12 -I/usr/include -I/usr/include/pycairo .sconf_temp/conftest_32.cpp
g++ -o .sconf_temp/conftest_32 .sconf_temp/conftest_32.o -Lagg -Lsrc -L/usr/lib64 -L/usr/local/lib64 -L/usr/local/lib -lfreetype -lxml2 -lcairomm-1.0 -lcairo -lm -lltdl -lpng -ltiff -lz -ljpeg -lproj -licuuc -lboost_system -lboost_filesystem -lboost_regex -lboost_iostreams -lboost_program_options -lboost_thread -lsqlite3 -lpq -lgdal
/usr/bin/ld: cannot find -lpq
collect2: ld returned 1 exit status
scons: Configure: Sorting lib and inc compiler paths by priority... internal,other,frameworks,user,system
scons: Configure: (cached) yes

}}}