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
相关推荐
物联网老王5 小时前
Ubuntu Linux Cursor 安装与使用一
linux·运维·ubuntu
fangeqin14 小时前
ubuntu源码安装python3.13遇到Could not build the ssl module!解决方法
linux·python·ubuntu·openssl
q5673152315 小时前
R语言初学者爬虫简单模板
开发语言·爬虫·r语言·iphone
风口上的吱吱鼠17 小时前
Armbian 25.5.1 Noble Gnome 开启远程桌面功能
服务器·ubuntu·armbian
笑衬人心。18 小时前
Ubuntu 22.04 + MySQL 8 无密码登录问题与 root 密码重置指南
linux·mysql·ubuntu
生如夏花℡18 小时前
HarmonyOS学习记录3
学习·ubuntu·harmonyos
星宸追风20 小时前
Ubuntu更换Home目录所在硬盘的过程
linux·运维·ubuntu
BD_Marathon20 小时前
Ubuntu下的Tomcat服务器部署
服务器·ubuntu·tomcat
好奇的菜鸟1 天前
如何在 Ubuntu 24.04 (Noble) 上使用阿里源
linux·运维·ubuntu
好奇的菜鸟1 天前
如何在Ubuntu上检查MySQL是否启动并放开3306端口
mysql·ubuntu·adb