Compiling ossfs on Rocky Linux 9

ossfs allows you to mount the object storage OSS bucket to the local file system in a Linux environment, enabling you to manipulate OSS objects just like local files, facilitating data sharing.

Operating Environment:Rocky Linux release 9.2 (Blue Onyx)

1. Dependency Packages

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

2. Compiling libfuse from Source

Compiling ossfs requires downloading the source package for libfuse instead of using the system’s built-in version. The steps are as follows:

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
make
make install

During the make process, you may encounter the following error:

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 1
make[2]: Leaving directory '/root/libfuse-fuse-2.9.9/util'
make[1]: *** [Makefile:338: all] Error 2
make[1]: Leaving directory '/root/libfuse-fuse-2.9.9/util'
make: *** [Makefile:450: all-recursive] Error 1

The reason is that the function defined in line 127 of ulockmgr_server.c, static int closefrom(int minfd), conflicts with the definition in /usr/include/unistd.h. Renaming the function in ulockmgr_server.c will resolve the issue.

After successfully compiling and installing libfuse, you need to modify /etc/ld.so.conf to include:

vim /etc/ld.so.conf
/usr/local/lib # Modify to the installation directory of your compiled libfuse
# After modification, execute ldconfig -v
3. Compiling ossfs
git clone https://github.com/aliyun/ossfs.git
cd ossfs
# The following two steps are crucial
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/:/usr/local/lib/pkgconfig
pkg-config --modversion fuse
./configure
make
make install

During the execution of configure, you may encounter the following error:

checking pkg-config is at least version 0.9.0... yes
checking 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.

The reason is that libfuse is incompatible; recompiling libfuse as described above will resolve the issue.

Leave a Comment