由于libiconv链接错误

时间:2016-08-10 17:34:02

标签: c++ macos osx-elcapitan gdal iconv

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

我们使用GDAL 1.11.x作为我们其中一个项目的依赖项 - 目前我们无法更新到GDAL 2.x,因为遗留的软件问题与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网站上找到的文档做了minimal configuration

$ ./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

有没有人遇到这样的事情?有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我在使用gdal的文件中遇到此错误,我必须在我的cmakelist中添加: 优化的iconv调试iconv

我知道这与你正在寻找的有点不同。你试过Gdal 1.11.1吗?

另外,你是从清洁开始的吗?我们一直遇到问题。

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

GDAL配置文件或makefile中是否有要设置的标志?很抱歉是通用的。我小组中的其他人建造了这个。补充:我看到你上面列出的标志,但也许有一个GDAL标志用来告诉它iconv的位置。