Rocky Linux 9 编译ossfs

简介: 介绍如何在Rocky Linux 9下编译阿里云的ossfs,本方法对CentOS 9 stream也适用。

ossfs能让您在Linux系统中,将对象存储OSS的存储空间(Bucket)挂载到本地文件系统中,您能够像操作本地文件一样操作OSS的对象(Object),实现数据的共享。

运行环境:Rocky Linux release 9.2 (Blue Onyx)

一、依赖包

dnf install gcc-c++ autoconf automake libtool libcurl-devel gettext-devel

二、源码编译libfuse

编译ossfs无法使用系统自带的libfuse,需要下载源码包自行编译,方法如下:

wget https://github.com/libfuse/libfuse/archive/refs/tags/fuse-2.9.9.tar.gz
tar zxvf fuse-2.9.9.tar.gz
cd libfuse-fuse-2.9.9
./makeconf.sh
./configure
makemake install

make时可能会报如下错误:

make[2]: Entering directory '/root/libfuse-fuse-2.9.9/util'  CC       fusermount-fusermount.o
  CC       fusermount-mount_util.o
  CCLD     fusermount
  CC       ulockmgr_server-ulockmgr_server.o
ulockmgr_server.c:127:12: error: conflicting types for ‘closefrom’; have ‘int(int)’
127 | static int closefrom(int minfd)
      |            ^~~~~~~~~
In file included from ulockmgr_server.c:14:
/usr/include/unistd.h:363:13: note: previous declaration of ‘closefrom’ with type ‘void(int)’
363 | extern void closefrom (int __lowfd) __THROW;
      |             ^~~~~~~~~
make[2]: *** [Makefile:509: ulockmgr_server-ulockmgr_server.o] Error 1make[2]: Leaving directory '/root/libfuse-fuse-2.9.9/util'make[1]: *** [Makefile:338: all] Error 2make[1]: Leaving directory '/root/libfuse-fuse-2.9.9/util'make: *** [Makefile:450: all-recursive] Error 1

原因是ulockmgr_server.c第127行定义的函数static int closefrom(int minfd)与/usr/include/unistd.h中的定义冲突了,给ulockmgr_server.c中的函数改个名字就好了。

编译安装好libfuse后,需要修改/etc/ld.so.conf,加入:

vim /etc/ld.so.conf
/usr/local/lib # 自己编译的libfuse安装目录修改后执行ldconfig -v

三、编译ossfs

git clone https://github.com/aliyun/ossfs.git
cd ossfs
# 下面这两步很重要exportPKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/:/usr/local/lib/pkgconfig
pkg-config --modversion fuse
./configure
makemake install

执行configure时可能会报下面的错误:

checking pkg-config is at least version 0.9.0... yeschecking for common_lib_checking... no
configure: error: Package requirements (fuse >=2.8.4 libcurl >=7.0 libxml-2.0 >=2.6 ) were not met:
Package 'fuse', required by 'virtual:world', not found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

原因就是libfuse不兼容,按上面的方法重新编译libfuse即可。


目录
相关文章
|
8天前
|
Linux 开发工具 C语言
Linux 安装 gcc 编译运行 C程序
Linux 安装 gcc 编译运行 C程序
31 0
|
3月前
|
监控 关系型数据库 Linux
|
3月前
|
Ubuntu Linux 编译器
Linux应用开发基础知识——交叉编译与gcc编译(一)
Linux应用开发基础知识——交叉编译与gcc编译(一)
66 0
Linux应用开发基础知识——交叉编译与gcc编译(一)
|
5月前
|
Linux 编译器 C语言
《Linux从练气到飞升》No.05 Linux编译器gcc/g++的使用及编译过程 【云边有个小卖部】上新
《Linux从练气到飞升》No.05 Linux编译器gcc/g++的使用及编译过程 【云边有个小卖部】上新
62 0
|
5月前
|
Linux C语言
在Linux中使用gcc/g++编译代码
1.方法速记 直接编译语法:将text.c文件或者text.cpp文件直接编译成text文件。 gcc text.c -o text // gcc-o text.c text g++ text.cpp -o text // g++ text.cpp -o text
45 0
|
7天前
|
Linux 开发工具 Android开发
Docker系列(1)安装Linux系统编译Android源码
Docker系列(1)安装Linux系统编译Android源码
14 0
|
5月前
|
Linux
Linux|编译最新版的openssh-server-9.3的rpm包的使用方法(二)
Linux|编译最新版的openssh-server-9.3的rpm包的使用方法(二)
109 0
|
29天前
|
Linux 编译器 Windows
【Linux】新唐NUC977系统编译及烧写流程
【Linux】新唐NUC977系统编译及烧写流程
|
2月前
|
Linux 开发工具 C语言
【研究Qt webengine 模块编译】linux 交叉编译qt5.12的webengine模块成功的条件
【研究Qt webengine 模块编译】linux 交叉编译qt5.12的webengine模块成功的条件
82 1
|
3月前
|
Java Linux 开发工具
Azkaban【部署 01】Linux环境 CentOS Linux release 7.5.1804安装配置azkaban-3.70.0编译阶段(附安装包及gradle-4.6资源)
【2月更文挑战第4天】Linux环境 CentOS Linux release 7.5.1804安装配置azkaban-3.70.0编译阶段(附安装包及gradle-4.6资源)
34 1