Fedora系统安装R的rgdal包报错:GDALAllRegister not found in libgdal
在Fedora上安装R的rgdal包时遇到
configure: error: GDALAllRegister not found in libgdal错误的解决求助 在Fedora平台尝试安装R的rgdal包时,出现错误提示configure: error: GDALAllRegister not found in libgdal,此前Ubuntu平台的同类解决方案无效,现附上详细报错日志并寻求帮助:
> install.packages("rgdal") Installiere Paket nach ‘/home/user/R/x86_64-redhat-linux-gnu-library/4.2’ (da ‘lib’ nicht spezifiziert) versuche URL 'https://cran.rstudio.com/src/contrib/rgdal_1.6-5.tar.gz' Content type 'application/x-gzip' length 4465310 bytes (4.3 MB) ================================================== downloaded 4.3 MB * installing *source* package ‘rgdal’ ... ** Paket ‘rgdal’ erfolgreich entpackt und MD5 Summen überprüft ** using staged installation configure: R_HOME: /usr/lib64/R configure: CC: gcc configure: CXX: g++ -std=gnu++14 configure: CFLAGS: -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection configure: CPPFLAGS: -I/usr/local/include configure: CXXFLAGS: -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection configure: LDFLAGS: -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 configure: LDFLAGS: -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 configure: CXX17 is: g++, CXX17STD is: -std=gnu++17 configure: CXX is: g++ -std=gnu++17 configure: C++17 support available configure: rgdal: 1.6-5 checking for /usr/bin/svnversion... no configure: svn revision: 1199 checking for gdal-config... /usr/bin/gdal-config checking gdal-config usability... yes configure: GDAL: 3.5.2 checking GDAL version != 3.6.0... yes checking GDAL version >= 1.11.4... yes checking GDAL version <= 2.5 or >= 3.0... yes checking GDAL: linking with --libs only... no checking GDAL: linking with --libs and --dep-libs... no /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQcmdStatus@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQfname@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQsetNoticeProcessor@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQftable@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQcancel@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQstatus@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQftablecol@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQconnectdb@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQescapeStringConn@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `lo_close@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQputCopyEnd@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQgetvalue@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQgetisnull@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQftype@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQfmod@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `lo_creat@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQresultStatus@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `lo_read@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQexec@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQsetClientEncoding@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQgetlength@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQputCopyData@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQgetResult@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `lo_write@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQfinish@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQclear@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQerrorMessage@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQnfields@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `lo_open@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQexecParams@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQgetCancel@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQntuples@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQresultErrorMessage@RHPG_9.6' /usr/bin/ld: /usr/lib64/libgdal.so: undefined reference to `PQfreeCancel@RHPG_9.6' collect2: error: ld returned 1 exit status /usr/bin/ld: cannot find -lodbcinst: No such file or directory /usr/bin/ld: cannot find -larmadillo: No such file or directory /usr/bin/ld: cannot find -lqhull_r: No such file or directory /usr/bin/ld: cannot find -lgeotiff: No such file or directory /usr/bin/ld: cannot find -lLerc: No such file or directory /usr/bin/ld: cannot find -lpoppler: No such file or directory /usr/bin/ld: cannot find -lgif: No such file or directory /usr/bin/ld: cannot find -lnetcdf: No such file or directory /usr/bin/ld: cannot find -lcfitsio: No such file or directory /usr/bin/ld: cannot find -lhdf5: No such file or directory /usr/bin/ld: cannot find -lgta: No such file or directory /usr/bin/ld: cannot find -lwebp: No such file or directory /usr/bin/ld: cannot find -ldf: No such file or directory /usr/bin/ld: cannot find -lmfhdf: No such file or directory /usr/bin/ld: cannot find -lopenjp2: No such file or directory /usr/bin/ld: cannot find -lOpenEXR: No such file or directory /usr/bin/ld: cannot find -lOpenEXRUtil: No such file or directory /usr/bin/ld: cannot find -lImath: No such file or directory /usr/bin/ld: cannot find -lIex: No such file or directory /usr/bin/ld: cannot find -lkmlbase: No such file or directory /usr/bin/ld: cannot find -lkmldom: No such file or directory /usr/bin/ld: cannot find -lkmlengine: No such file or directory /usr/bin/ld: cannot find -lspatialite: No such file or directory /usr/bin/ld: cannot find -lsqlite3: No such file or directory /usr/bin/ld: cannot find -lxerces-c: No such file or directory /usr/bin/ld: cannot find -lmysqlclient: No such file or directory /usr/bin/ld: cannot find -lodbc: No such file or directory /usr/bin/ld: cannot find -lfreexl: No such file or directory /usr/bin/ld: cannot find -logdi: No such file or directory /usr/bin/ld: cannot find -lexpat: No such file or directory /usr/bin/ld: cannot find -lgeos_c: No such file or directory /usr/bin/ld: cannot find -lproj: No such file or directory /usr/bin/ld: cannot find -ljson-c: No such file or directory collect2: error: ld returned 1 exit status configure: Install failure: compilation and/or linkage problems. configure: error: GDALAllRegister not found in libgdal. ERROR: configuration failed for package ‘rgdal’ * removing ‘/home/user/R/x86_64-redhat-linux-gnu-library/4.2/rgdal’ Warning in install.packages : Installation des Pakets ‘rgdal’ hatte Exit-Status ungleich 0
针对Fedora的解决方案
1. 安装完整的GDAL及依赖开发包
从报错日志看,大量依赖库缺失,PostgreSQL相关链接也有问题,执行以下命令安装所有必要的开发包:
sudo dnf install gdal-devel proj-devel geos-devel sqlite-devel libpq-devel libxml2-devel netcdf-devel hdf5-devel libwebp-devel openjpeg2-devel poppler-devel geotiff-devel
2. 验证GDAL配置
确认GDAL工具正常可用:
gdal-config --version gdal-config --libs
输出应包含GDAL版本(如3.5.2)和正确的库链接路径。
3. 指定编译参数安装rgdal
在R中执行以下命令,明确指定GDAL和PROJ的路径:
install.packages("rgdal", configure.args = c( "--with-gdal-config=/usr/bin/gdal-config", "--with-proj-include=/usr/include/proj", "--with-proj-lib=/usr/lib64" ))
4. 备选:安装预编译的rgdal包
如果编译仍然失败,直接使用Fedora官方仓库的预编译包,避免编译环节:
sudo dnf install R-rgdal
内容的提问来源于stack exchange,提问作者TobKel
相关产品推荐
相关产品推荐

