【问题标题】:Can't compile GDAL on OSX 1.11.6 due to libiconv link error由于 libiconv 链接错误,无法在 OSX 1.11.6 上编译 GDAL
【发布时间】:2016-08-10 17:34:01
【问题描述】:

我最近将我的 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

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

【问题讨论】:

  • 你弄明白了吗?

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


【解决方案1】:

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

我知道这与您要查找的内容有些不同。你试过 Gdal 1.11.1 吗?

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

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

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

【讨论】:

  • 您可以做的另一件事是自己构建 iconv 并告诉 GDAL 从哪里获取它。
  • 另外,您是否运行了配置?我假设您这样做了,因为您必须使用来自 configure 命令的内容来进行制作。如果你认为升级操作系统后不需要配置,那你可能错了。只是一个建议。我通常不在这里回答问题,而且我知道这是一个较旧的问题。
  • 此链接中有一些您没有使用的标志:trac.osgeo.org/gdal/wiki/BuildingOnMac
  • 另一个想法,gdal 是在寻找 iconv dylib 还是其他版本?
猜你喜欢
  • 2013-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-28
相关资源
最近更新 更多