Question

I am working on a very simple file system for learning purposes, which uses fuse. However, I cannot compile it:

$ gcc -Wall `pkg-config fuse --cflags --libs` myfs.c -o myfs
/tmp/cc6xhGKO.o: In function `main':
myfs.c:(.text+0x1602): undefined reference to `fuse_opt_add_arg'
myfs.c:(.text+0x164f): undefined reference to `fuse_main_real'
collect2: ld returned 1 exit status

pkg-config already appends -lfuse (see below).

My system infos:

$ uname -a
Linux fpti 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ dpkg -l | grep fuse
ii  fuse                            2.8.6-2ubuntu2             Filesystem in Userspace
ii  libfuse-dev                     2.8.6-2ubuntu2             Filesystem in Userspace (development)
ii  libfuse2                        2.8.6-2ubuntu2             Filesystem in Userspace (library)
$ pkg-config fuse --cflags --libs
-D_FILE_OFFSET_BITS=64 -I/usr/include/fuse  -pthread -lfuse -lrt -ldl
Was it helpful?

Solution

-l options need to be after the thing that needs them. The --libs output doesn't work because it's in the wrong place. Move it after myfs.c

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top