由于 libiconv 链接错误,无法在 OSX 1.11.6 上编译 GDAL

Can't compile GDAL on OSX 1.11.6 due to libiconv link error

本文关键字:GDAL 编译 OSX 链接 libiconv 错误 由于      更新时间:2023-10-16

我最近将OSX机器升级到OSX El Capitan(1.11.6),在编译GDAL 1.11.x时遇到了一个问题。我已经尝试了1.11.4和1.11.5,我得到了同样的结果。

我们使用GDAL 1.11。x依赖于我们的一个项目——现在我们不能更新到GDAL 2。因为在GDAL 2中已弃用的一些函数中存在遗留软件问题。x…

自从我的机器移动到El Capitan, GDAL 1.11。X构建失败,并在最后的链接步骤中显示以下链接器错误消息:

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C pdf
make[3]: Nothing to be done for `default'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make libgdal.la
/bin/sh /test/gdal-1.11.5/libtool --mode=link   g++    -L/opt/local/lib -lgeos_c  -lsqlite3 -lpthread -ldl               -liconv  -L/opt/local/lib -lxml2 -lz -lpthread -liconv -lm  -o libgdal.la /test/gdal-1.11.5/frmts/o/*.lo /test/gdal-1.11.5/gcore/*.lo /test/gdal-1.11.5/port/*.lo /test/gdal-1.11.5/alg/*.lo /test/gdal-1.11.5/ogr/ogrsf_frmts/o/*.lo ./ogr/ogrgeometryfactory.lo ./ogr/ogrpoint.lo ./ogr/ogrcurve.lo ./ogr/ogrlinestring.lo ./ogr/ogrlinearring.lo ./ogr/ogrpolygon.lo ./ogr/ogrutils.lo ./ogr/ogrgeometry.lo ./ogr/ogrgeometrycollection.lo ./ogr/ogrmultipolygon.lo ./ogr/ogrsurface.lo ./ogr/ogrmultipoint.lo ./ogr/ogrmultilinestring.lo ./ogr/ogr_api.lo ./ogr/ogrfeature.lo ./ogr/ogrfeaturedefn.lo ./ogr/ogrfeaturequery.lo ./ogr/ogrfeaturestyle.lo ./ogr/ogrfielddefn.lo ./ogr/ogrspatialreference.lo ./ogr/ogr_srsnode.lo ./ogr/ogr_srs_proj4.lo ./ogr/ogr_fromepsg.lo ./ogr/ogrct.lo ./ogr/ogr_opt.lo ./ogr/ogr_srs_esri.lo ./ogr/ogr_srs_pci.lo ./ogr/ogr_srs_usgs.lo ./ogr/ogr_srs_dict.lo ./ogr/ogr_srs_panorama.lo ./ogr/ogr_srs_ozi.lo ./ogr/ogr_srs_erm.lo ./ogr/swq.lo ./ogr/swq_expr_node.lo ./ogr/swq_parser.lo ./ogr/swq_select.lo ./ogr/swq_op_registrar.lo ./ogr/swq_op_general.lo ./ogr/ogr_srs_validate.lo ./ogr/ogr_srs_xml.lo ./ogr/ograssemblepolygon.lo ./ogr/ogr2gmlgeometry.lo ./ogr/gml2ogrgeometry.lo ./ogr/ogr_expat.lo ./ogr/ogrpgeogeometry.lo ./ogr/ogrgeomediageometry.lo ./ogr/ogr_geocoding.lo ./ogr/osr_cs_wkt.lo ./ogr/osr_cs_wkt_parser.lo ./ogr/ogrgeomfielddefn.lo 
    -rpath /usr/local/lib 
    -no-undefined 
    -version-info 19:5:18
libtool: link: g++ -dynamiclib  -o .libs/libgdal.1.dylib <snipped out the rest of the gigantic link line/>
Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      CPLRecodeIconv(char const*, char const*, char const*) in cpl_recode_iconv.o
      CPLRecodeFromWCharIconv(wchar_t const*, char const*, char const*) in cpl_recode_iconv.o
  "_iconv_close", referenced from:
      CPLRecodeIconv(char const*, char const*, char const*) in cpl_recode_iconv.o
      CPLRecodeFromWCharIconv(wchar_t const*, char const*, char const*) in cpl_recode_iconv.o
  "_iconv_open", referenced from:
      CPLRecodeIconv(char const*, char const*, char const*) in cpl_recode_iconv.o
      CPLRecodeFromWCharIconv(wchar_t const*, char const*, char const*) in cpl_recode_iconv.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libgdal.la] Error 1
make: *** [check-lib] Error 2

根据我在GDAL网站上找到的文档,我正在做一个最小的配置:

$ ./configure --with-netcdf=no 
              --with-jpeg=no 
              --with-threads 
              --with-ogr 
              --with-geos 
              --with-libz=internal 
              --with-libtiff=internal 
              --with-geotiff=internal 
              --without-gif 
              --without-pg 
              --without-grass 
              --without-libgrass 
              --without-cfitsio 
              --without-pcraster 
              --without-png 
              --without-gif 
              --without-ogdi 
              --without-fme 
              --without-hdf4 
              --without-hdf5 
              --without-jasper 
              --without-ecw 
              --without-kakadu 
              --without-mrsid 
              --without-jp2mrsid 
              --without-bsb 
              --without-grib 
              --without-mysql 
              --without-ingres 
              --without-xerces 
              --without-expat 
              --without-odbc 
              --without-curl 
              --without-dwgdirect 
              --without-idb 
              --without-sde 
              --without-perl 
              --without-php 
              --without-ruby 
              --with-hide-internal-symbols 
              --disable-rpath

我正在使用macports并安装了libiconv…

$ sudo port install libiconv
--->  Cleaning libiconv
--->  Scanning binaries for linking errors
--->  No broken files found.

/opt/local/lib也在我的LD_LIBRARY_PATH和DYLD_LIBRARY_PATH中,我验证了libiconv也在/opt/local/lib中:

> ll /opt/local/lib/*iconv*
lrwxr-xr-x  1 root  admin    16B Jan 29  2016 /opt/local/lib/libiconv.dylib@ -> libiconv.2.dylib
-rw-r--r--  1 root  admin   1.0M Jan 29  2016 /opt/local/lib/libiconv.a
-rw-r--r--  1 root  admin   1.0M Jan 29  2016 /opt/local/lib/libiconv.2.dylib

有人遇到过这样的东西吗?什么好主意吗?

我在一个使用gdal的文件中遇到了这个错误,我不得不把它添加到我的cmakelist中:优化iconv调试iconv

我知道这和你想要的有点不同。你尝试过Gdal 1.11.1吗?

还有,你是先打扫的吗?我们经常遇到这样的问题。

我查看我的PATH,而不是我的LD_LIBRARY_PATH(这是空白的),并看到/usr/bin,这是我的iconv所在的位置。

在GDAL配置文件或makefile中是否有任何要设置的标志?抱歉我说得太笼统了。这是我小组里的一个人做的。添加:我看到你上面列出的标志,但也许有一个GDAL标志来告诉它iconv在哪里。