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 小时前
CMake —— 2、cmake在windows与linux下动态链接库编译与链接实例(附:过程代码与CMakeLists.txt)
windows·ubuntu·cmake·动态链接库·linux\
矛取矛求7 小时前
VMware 安装 Ubuntu 全流程实战指南:从零搭建到深度优化
linux·运维·ubuntu
Hey! Hey!7 小时前
Ubuntu桌面系统安装VirtualBox教程
linux·运维·ubuntu
盗理者8 小时前
在win11 环境下 新安装 WSL ubuntu + 换国内镜像源 + ssh + 桌面环境 + Pyhton 环境 + vim 设置插件安装
ubuntu·ssh·vim
让子弹飞029 小时前
15.1linux设备树下的platform驱动编写(知识)_csdn
linux·ubuntu·platform·stm32mp157·驱动的分离和分层
松树戈12 小时前
Ubuntu挂载HDD迁移存储PostgreSQL数据
linux·ubuntu·postgresql
夏天里的肥宅水14 小时前
Windows连接服务器Ubuntu_MobaXterm
运维·服务器·ubuntu
学也不会17 小时前
Ubuntu-安装redis
linux·运维·ubuntu
深夜情感老师1 天前
centos&ububntu设置开机自启动
ubuntu·centos
liuliu03231 天前
戴尔笔记本 ubuntu 22.04 开机后进入initramfs界面
linux·运维·ubuntu