【发布时间】:2019-01-05 02:19:47
【问题描述】:
当我在将 R 从 3.4.4 更新到 3.5.1 之后通过从源代码编译来更新(或至少尝试)rgdal 包时,我遇到了一个奇怪的问题,一切顺利,但由于命名空间加载失败到“未定义符号”错误:
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/rgdal/libs/rgdal.so':
/usr/local/lib/R/site-library/rgdal/libs/rgdal.so: undefined symbol: _ZNK10OGRFeature16GetFieldAsDoubleEi
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/rgdal’
* restoring previous ‘/usr/local/lib/R/site-library/rgdal’
The downloaded source packages are in
‘/tmp/RtmpHu6D0N/downloaded_packages’
Warning message:
In install.packages("rgdal") :
installation of package ‘rgdal’ had non-zero exit status
运行echo _ZNK10OGRFeature16GetFieldAsDoubleEi | c++filt 时,我得到OGRFeature::GetFieldAsDouble(int) const 的输出,这对我了解不多。我已经从 https://trac.osgeo.org/gdal/wiki/DownloadSource 安装了 GDAL,正如 CRAN 软件包站点上所建议的那样,这表明我安装了 GDAL 2.3.1。
更新失败很奇怪,因为软件包已经安装,所以应该满足依赖关系。热烈欢迎任何有关如何解决此问题的指示。
由于过去几周没有收到任何建议,我决定卸载 rgdal,然后重新安装。有趣的是,现在我声称我的系统(Ubuntu 16.04.5 LTS)不支持 C++11,尽管检查显示它在那里(C++11 support available):
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /usr/lib/R
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... yes
configure: svn revision: 766
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.3.1
checking C++11 support for GDAL >= 2.3.0... yes
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
In file included from /usr/local/include/gdal.h:45:0,
from gdal_test.cc:1:
/usr/local/include/cpl_port.h:187:6: error: #error Must have C++11 or newer.
# error Must have C++11 or newer.
^
In file included from /usr/local/include/gdal.h:49:0,
from gdal_test.cc:1:
/usr/local/include/cpl_minixml.h:202:47: error: expected template-name before '<' token
class CPLXMLTreeCloser: public std::unique_ptr<CPLXMLNode, CPLXMLTreeCloserDeleter>
^
/usr/local/include/cpl_minixml.h:202:47: error: expected '{' before '<' token
/usr/local/include/cpl_minixml.h:202:47: error: expected unqualified-id before '<' token
In file included from /usr/local/include/ogr_api.h:45:0,
from /usr/local/include/gdal.h:50,
from gdal_test.cc:1:
/usr/local/include/ogr_core.h:79:28: error: expected '}' before end of line
/usr/local/include/ogr_core.h:79:28: error: expected declaration before end of line
In file included from /usr/local/include/gdal.h:45:0,
from gdal_test.cc:1:
/usr/local/include/cpl_port.h:187:6: error: #error Must have C++11 or newer.
# error Must have C++11 or newer.
^
In file included from /usr/local/include/gdal.h:49:0,
from gdal_test.cc:1:
/usr/local/include/cpl_minixml.h:202:47: error: expected template-name before '<' token
class CPLXMLTreeCloser: public std::unique_ptr<CPLXMLNode, CPLXMLTreeCloserDeleter>
^
/usr/local/include/cpl_minixml.h:202:47: error: expected '{' before '<' token
/usr/local/include/cpl_minixml.h:202:47: error: expected unqualified-id before '<' token
In file included from /usr/local/include/ogr_api.h:45:0,
from /usr/local/include/gdal.h:50,
from gdal_test.cc:1:
/usr/local/include/ogr_core.h:79:28: error: expected '}' before end of line
/usr/local/include/ogr_core.h:79:28: error: expected declaration before end of line
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/usr/local/lib/R/site-library/rgdal’
我的devtools::session_info() 如下:
Session info ------------------------------------------------------------------
setting value
version R version 3.5.1 (2018-07-02)
system x86_64, linux-gnu
ui X11
language en_US:en
collate en_US.UTF-8
tz Europe/Brussels
date 2018-07-28
Packages ----------------------------------------------------------------------
package * version date source
base * 3.5.1 2018-07-03 local
compiler 3.5.1 2018-07-03 local
datasets * 3.5.1 2018-07-03 local
devtools * 1.13.6 2018-06-27 CRAN (R 3.5.1)
digest 0.6.15 2018-01-28 CRAN (R 3.5.1)
graphics * 3.5.1 2018-07-03 local
grDevices * 3.5.1 2018-07-03 local
memoise 1.1.0 2017-04-21 CRAN (R 3.5.1)
methods * 3.5.1 2018-07-03 local
stats * 3.5.1 2018-07-03 local
tools 3.5.1 2018-07-03 local
utils * 3.5.1 2018-07-03 local
withr 2.1.2 2018-03-15 CRAN (R 3.5.1)
【问题讨论】: