[Nix-dev] libtool + gdal 1.9.0 unhappiness

Bryce L Nordgren bnordgren at gmail.com
Sat Feb 11 23:06:37 CET 2012


I've been beating my head against a wall trying to get postgis 2.0.0 alpha4
to compile on Nixos for the past couple of days. I've narrowed my problem
down to "anything which tries to link against gdal using libtool will
fail." I made a super simple gdal test program (print gdal version then
exit) to demonstrate. I can see what libtool is doing, and I can see what
NEEDS to happen, but I have no idea how to affect what libtool does. My
gdal nix expression has been updated to the current version, and is
attached.  Please help if you can.

[root at postgis:~/gdaltest]# cat test.c
#include <stdio.h>
#include <gdal.h>

int
main(int ac, char **av)  {

  printf("%s\n", GDALVersionInfo("--version")) ;

  return 0 ;
}

And here, step by step, is the compile and link process:

[root at postgis:~/gdaltest]# cflags=`gdal-config --cflags`

[root at postgis:~/gdaltest]# echo $cflags
-I/nix/store/0m3hxnk515yw2bnrqb69aqw0hikl51l9-gdal-1.9.0/include

[root at postgis:~/gdaltest]# libtool --mode=compile --tag=CC gcc $cflags -c
test.c
libtool: compile:  gcc
-I/nix/store/0m3hxnk515yw2bnrqb69aqw0hikl51l9-gdal-1.9.0/include -c test.c
-fPIC -DPIC -o .libs/test.o

So far so good. Here's where it all turns pear shaped.

[root at postgis:~/gdaltest]# libs=`gdal-config --libs`

[root at postgis:~/gdaltest]# echo $libs
-L/nix/store/0m3hxnk515yw2bnrqb69aqw0hikl51l9-gdal-1.9.0/lib -lgdal

[root at postgis:~/gdaltest]# libtool --mode=link --tag=CC gcc $libs -o test
test.lo
libtool: link: gcc -o test .libs/test.o
-L/nix/store/0m3hxnk515yw2bnrqb69aqw0hikl51l9-gdal-1.9.0/lib
/nix/store/0m3hxnk515yw2bnrqb69aqw0hikl51l9-gdal-1.9.0/lib/libgdal.so
-L/nix/store/q9dpk0kdyfql0m72bp4bcmccbh5mgifg-libjpeg-8c
-L/nix/store/7lp85113g806y94gwi1zs2n8lgv8v92d-libgeotiff-1.2.4/lib
-L/nix/store/ywf340c821pmiz4aqjhgn9s36ynnmswz-libtiff-3.9.4/lib
-L/nix/store/lr40r8rgvnf18zbfpwz9r6i02q3p1ghy-postgresql-9.0.5/lib
-L/nix/store/pv49msy9ylg9zhhf35fa9lkssgb8d5qx-zlib-1.2.5
-L/nix/store/pv49msy9ylg9zhhf35fa9lkssgb8d5qx-zlib-1.2.5/lib
-L/nix/store/1nrrsszgpgwv16m5ki879wn18vx0ksas-mysql-5.1.54/lib/mysql
-L/nix/store/lyp9mjsaamp7qsrnl115j75zhwm712xp-openssl-1.0.0e/lib/ -lgeotiff
/nix/store/ywf340c821pmiz4aqjhgn9s36ynnmswz-libtiff-3.9.4/lib/libtiff.so
-lc -ljpeg
/nix/store/q9dpk0kdyfql0m72bp4bcmccbh5mgifg-libjpeg-8c/lib/libjpeg.so -lpq
-lpthread -lrt -ldl
/nix/store/1nrrsszgpgwv16m5ki879wn18vx0ksas-mysql-5.1.54/lib/mysql/libmysqlclient.so
-lz -lcrypt -lnsl -lssl -lcrypto
/nix/store/3r8kfi33y3lbrsvlx8vzwm74h8178y35-gcc-4.5.1/lib/../lib64/libstdc++.so
-lm -Wl,-rpath
-Wl,/nix/store/0m3hxnk515yw2bnrqb69aqw0hikl51l9-gdal-1.9.0/lib -Wl,-rpath
-Wl,/nix/store/ywf340c821pmiz4aqjhgn9s36ynnmswz-libtiff-3.9.4/lib
-Wl,-rpath -Wl,/nix/store/q9dpk0kdyfql0m72bp4bcmccbh5mgifg-libjpeg-8c/lib
-Wl,-rpath
-Wl,/nix/store/1nrrsszgpgwv16m5ki879wn18vx0ksas-mysql-5.1.54/lib/mysql
-Wl,-rpath
-Wl,/nix/store/3r8kfi33y3lbrsvlx8vzwm74h8178y35-gcc-4.5.1/lib/../lib64
-Wl,-rpath -Wl,/nix/store/0m3hxnk515yw2bnrqb69aqw0hikl51l9-gdal-1.9.0/lib
-Wl,-rpath
-Wl,/nix/store/ywf340c821pmiz4aqjhgn9s36ynnmswz-libtiff-3.9.4/lib
-Wl,-rpath -Wl,/nix/store/q9dpk0kdyfql0m72bp4bcmccbh5mgifg-libjpeg-8c/lib
-Wl,-rpath
-Wl,/nix/store/1nrrsszgpgwv16m5ki879wn18vx0ksas-mysql-5.1.54/lib/mysql
-Wl,-rpath
-Wl,/nix/store/3r8kfi33y3lbrsvlx8vzwm74h8178y35-gcc-4.5.1/lib/../lib64
/nix/store/9b3q62czfh5zld9zg2p8sbk65hkbvpzi-binutils-2.21/bin/ld: cannot
find -ljpeg
collect2: ld returned 1 exit status

Note that it would be able to find -ljpeg if only there was an extra
".../lib" at the end of this:
-L/nix/store/q9dpk0kdyfql0m72bp4bcmccbh5mgifg-libjpeg-8c . It doesn't even
need to say -ljpeg at all, since it includes the full path to the library
via: /nix/store/q9dpk0kdyfql0m72bp4bcmccbh5mgifg-libjpeg-8c/lib/libjpeg.so

Any ideas?

Bryce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20120211/ffd3ed02/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: default.nix
Type: application/octet-stream
Size: 1045 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20120211/ffd3ed02/attachment.obj 


More information about the nix-dev mailing list