R虚拟环境中安装ncdf4库包编译库问题

目录

R虚拟环境中安装ncdf4的问题

解决方案


R虚拟环境中安装ncdf4的问题

> install.packages("ncdf4")
trying URL 'https://mirrors.bfsu.edu.cn/CRAN/src/contrib/ncdf4_1.23.tar.gz'
Content type 'application/octet-stream' length 125897 bytes (122 KB)

downloaded 122 KB

* installing *source* package 'ncdf4' ...
** package 'ncdf4' successfully unpacked and MD5 sums checked
** using staged installation
configure.ac: starting
checking for nc-config... yes
Using nc-config: nc-config
Output of nc-config --all:

This netCDF 4.9.2 has been built with the following features:

--cc -> /usr/bin/cc
--cflags -> -I/usr/include -I/usr/include/hdf5/serial
--libs -> -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf
--static -> -lhdf5_hl -lhdf5 -lcrypto -lcurl -lpthread -lsz -lz -ldl -lm -lxml2

--has-dap -> yes
--has-dap2 -> yes
--has-dap4 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--has-hdf5 -> yes
--has-hdf4 -> no
--has-logging -> no
--has-pnetcdf -> no
--has-szlib -> no
--has-cdf5 -> yes
--has-parallel4 -> no
--has-parallel -> no
--has-nczarr -> yes
--has-zstd -> yes
--has-benchmarks -> no
--has-multifilters -> no
--has-stdfilters -> deflate szip bz2
--has-quantize -> no

--prefix -> /usr
--includedir -> /usr/include
--libdir -> /usr/lib/x86_64-linux-gnu
--plugindir ->
--version -> netCDF 4.9.2


netcdf.m4: about to set rpath, here is source string: >-L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf<
netcdf.m4: final rpath: -Wl,-rpath,/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu/hdf5/serial
Netcdf library version: netCDF 4.9.2
Netcdf library has version 4 interface present: yes
Netcdf library was compiled with C compiler: /usr/bin/cc
configure: creating ./config.status
config.status: creating src/Makevars

********************** Results of ncdf4 package configure *******************

netCDF v4 CPP flags = -I/usr/include -I/usr/include/hdf5/serial
netCDF v4 LD flags = -Wl,-rpath,/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu/hdf5/serial -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/langyang/Tools/anaconda3/2024.02/envs/R/lib -Wl,-rpath-link,/home/langyang/Tools/anaconda3/2024.02/envs/R/lib -L/home/langyang/Tools/anaconda3/2024.02/envs/R/lib
netCDF v4 runtime path = -Wl,-rpath,/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu/hdf5/serial

netCDF C compiler used = /usr/bin/cc
R C compiler used = x86_64-conda-linux-gnu-cc -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/langyang/Tools/anaconda3/2024.02/envs/R/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/r-base-split_1732138515749/work=/usr/local/src/conda/r-base-4.4.2 -fdebug-prefix-map=/home/langyang/Tools/anaconda3/2024.02/envs/R=/usr/local/src/conda-prefix

******************************************************************************

checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether x86_64-conda-linux-gnu-cc accepts -g... yes
checking for x86_64-conda-linux-gnu-cc option to accept ISO C89... none needed
checking whether we are using the GNU C compiler... (cached) yes
checking whether x86_64-conda-linux-gnu-cc accepts -g... (cached) yes
checking for x86_64-conda-linux-gnu-cc option to accept ISO C89... (cached) none needed
netcdf cc arg1: /usr/bin/cc R cc arg1: x86_64-conda-linux-gnu-cc R_IS_GCC: 1 R_IS_CLANG: 0 NETCDF_IS_GCC: 1 NETCDF_IS_CLANG: 0 emit_warning: 0
** libs
using C compiler: 'x86_64-conda-linux-gnu-cc (conda-forge gcc 14.2.0-1) 14.2.0'
x86_64-conda-linux-gnu-cc -I"/home/langyang/Tools/anaconda3/2024.02/envs/R/lib/R/include" -DNDEBUG -I/usr/include -I/usr/include/hdf5/serial -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/langyang/Tools/anaconda3/2024.02/envs/R/include -I/home/langyang/Tools/anaconda3/2024.02/envs/R/include -Wl,-rpath-link,/home/langyang/Tools/anaconda3/2024.02/envs/R/lib -fpic -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/langyang/Tools/anaconda3/2024.02/envs/R/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/r-base-split_1732138515749/work=/usr/local/src/conda/r-base-4.4.2 -fdebug-prefix-map=/home/langyang/Tools/anaconda3/2024.02/envs/R=/usr/local/src/conda-prefix -c ncdf.c -o ncdf.o
In file included from ncdf.c:2:
/usr/include/stdio.h:28:10: fatal error: bits/libc-header-start.h: No such file or directory
28 | #include <bits/libc-header-start.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [/home/langyang/Tools/anaconda3/2024.02/envs/R/lib/R/etc/Makeconf:197: ncdf.o] Error 1
ERROR: compilation failed for package 'ncdf4'
* removing '/home/langyang/Tools/anaconda3/2024.02/envs/R/lib/R/library/ncdf4'

The downloaded source packages are in
'/tmp/RtmpHKNVpO/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("ncdf4") :
installation of package 'ncdf4' had non-zero exit status

安装nc-config文件

bash 复制代码
sudo apt install netcdf-bin
sudo apt install libnetcdf-dev
bash 复制代码
install.packages("devtools")

解决方案

参考https://stackoverflow.com/questions/54082459/fatal-error-bits-libc-header-start-h-no-such-file-or-directory-while-compili

原因是:使用了-32指令,我的服务器是64位的,无法直接编译执行32位机器指令

Install 32-bit headers and libraries. Here's how you'd do this on Ubuntu.

Run this command:

bash 复制代码
sudo apt install gcc-multilib

卸载nc-config文件

bash 复制代码
sudo apt remove --auto-remove libnetcdf-dev
相关推荐
AAIshangyanxiu5 小时前
基于R语言的物种气候生态位动态量化与分布特征模拟-组合物种分布模型(Ensemble Species Distribution Model)
r语言·物种分布·物种气候生态位·物种气候
云和数据.ChenGuang13 小时前
r=re.search(r‘data-original=“(.*?)“‘, line)指令解析
数据库·mysql·r语言
2301_7833601313 小时前
R语言机器学习系列|随机森林模型特征重要性排序的R语言实现
随机森林·机器学习·r语言
hakukun13 小时前
Ubuntu启动时volume报错无法进入系统问题解决
linux·ubuntu
brucelee18617 小时前
在 Linux Ubuntu 24.04 安装 IntelliJ IDEA
linux·ubuntu·intellij-idea
维维180-3121-145518 小时前
R语言物种分布建模:算法比较、生态位量化与论文图表制作
r语言·生态学·环境·农业·林业·生物地理
hero_heart1 天前
ubuntu 密码重置(不用系统盘)
linux·运维·ubuntu
小艳加油1 天前
生态学研究突破:利用R语言多元算法实现物种气候生态位动态分析与分布预测,涵盖数据清洗、模型评价到论文写作全流程
开发语言·算法·r语言
以琦琦为中心1 天前
很好!从 `fdisk -l` 输出可以看到您的磁盘确实是600GB,但只有29.5GB被分配给根分区 `/dev/sda3`。现在我来帮您扩展这个分区。
linux·ubuntu
艾莉丝努力练剑1 天前
【Linux基础开发工具 (三)】Vim从入门到精通(下):效率翻倍的编辑技巧与个性化配置攻略
linux·运维·服务器·c++·ubuntu·centos·vim