【问题标题】:More problems installing rgdal on Ubuntu 16.04 - undefined symbol在 Ubuntu 16.04 上安装 rgdal 的更多问题 - 未定义符号
【发布时间】:2018-08-09 21:08:02
【问题描述】:

我一直在讨论如何在 Ubuntu 16.04 上安装 rgdal 的许多线程上尝试各种建议,但仍然遇到问题。

这是我经过多次错误尝试后到达的地方。我在这里尝试了答案(trouble in installing rgdal on ubuntu 16.04):

sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal libgdal1-dev

这大部分都有效,除了 libgdal1-dev,我的包管理器说可用版本是 1.11.3,这似乎给我带来了困难(不确定我在这个阶段是否可以复制),所以我使用 Synaptic 来卸载该软件包并安装 libgdal-dev,它已被 Synaptic 标记。

所以此时,根据 Synaptic 的说法,当我搜索“gdal”时,显示的已安装文件是 gdal-bin、gdal-data、libgdal-dev、libgdal20、python-gdal 和 python3- gdal。

此时,当我打开 R 并运行 install.packages("rgdal") 时,这就是我得到的结果:

Installing package into ‘/home/[username]/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rgdal_1.3-4.tar.gz'
Content type 'application/x-gzip' length 1664774 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

* 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... no
configure: svn revision: 766
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.2
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/share/gdal/2.2/pcs.csv readable... yes
configure: pkg-config proj exists, will use it
configure: PROJ version: 4.9.2
checking proj_api.h presence and usability... yes
checking PROJ version >= 4.8.0... yes
checking projects.h presence and usability... yes
checking PROJ.4: epsg found and readable... yes
checking PROJ.4: conus found and readable... yes
configure: Package CPP flags:  -I/usr/include/gdal
configure: Package LIBS:  -L/usr/lib -lgdal -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c OGR_write.cpp -o OGR_write.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal-bindings.cpp -o gdal-bindings.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c inverser.c -o inverser.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c local_stubs.c -o local_stubs.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogr_geom.cpp -o ogr_geom.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ogr_polygons.c -o ogr_polygons.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogr_proj.cpp -o ogr_proj.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogrdrivers.cpp -o ogrdrivers.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c ogrsource.cpp -o ogrsource.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I"/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/sp/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c projectit.cpp -o projectit.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o rgdal.so OGR_write.o gdal-bindings.o init.o inverser.o local_stubs.o ogr_geom.o ogr_polygons.o ogr_proj.o ogrdrivers.o ogrsource.o projectit.o -L/usr/lib -lgdal -lproj -L/usr/lib/R/lib -lR
installing to /home/[username]/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** 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 '/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs/rgdal.so':
  /home/[username]/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs/rgdal.so: undefined symbol: _ZN10OGRFeature17GetFieldAsIntegerEi
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/[username]/R/x86_64-pc-linux-gnu-library/3.4/rgdal’

The downloaded source packages are in
    ‘/tmp/Rtmpuc6qcT/downloaded_packages’
Warning message:
In install.packages("rgdal") :
  installation of package ‘rgdal’ had non-zero exit status

我搜索了错误信息,发现了这个问题(Cannot install rgdal package in R on RHEL6, unable to load shared object rgdal.so),所以尝试运行

ldconfig -c "echo '/usr/local/lib' >> /etc/ld.so.conf.d/R-dependencies-x86_64.conf"

但它似乎没有做任何事情,当我尝试安装 rgdal 时仍然收到相同的错误消息。

我从这里去哪里?

【问题讨论】:

    标签: r ubuntu-16.04 gdal rgdal


    【解决方案1】:

    我在Ubuntu 18.04 上,但我遇到了同样的问题(完全相同的错误日志),我的解决方案是将rgdal 链接到gdal 的自定义构建。我很幸运,由于其他原因,我已经拥有了一份GDAL(git master)的副本,该副本是从/usr/local/gdal 中的源代码构建的。所以要从源代码安装rgdal,我只需要:

    • wget https://cran.r-project.org/src/contrib/rgdal_1.3-4.tar.gz
    • sudo R CMD INSTALL --configure-args=--with-gdal-config=/usr/local/gdal/bin/gdal-config rgdal_1.3-4.tar.gz

    如果你走这条路,请确保你的 gdal 安装已将所有投影数据安装在预期的位置,我的没有,所以我不得不添加一个额外的步骤:

    • sudo cp -r /path/to/gdal-src-code/gdal/data/* /usr/local/gdal/share/gdal/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-16
      • 1970-01-01
      • 2018-04-18
      • 2017-11-07
      • 2018-10-11
      • 1970-01-01
      • 2019-10-20
      • 2016-01-16
      相关资源
      最近更新 更多