42

I have added a new function (fuse_lowlevel_notify_inval_directory) in user space fuse library. The compilation and creation of libfuse.so is finished without error. But when my application tries to use this new function, the linker is throwing error: undefined reference to `fuse_lowlevel_notify_inval_directory' collect2: ld returned 1 exit status

When I checked with nm

nm ../libfuse.so | grep inval
00000000000154ed T fuse_invalidate
**000000000001e142 t fuse_lowlevel_notify_inval_directory**
000000000001e26c T fuse_lowlevel_notify_inval_entry
000000000001e1cb T fuse_lowlevel_notify_inval_inode

T/t means the symbol is present in text section. if uppercase, the symbol is global (external). I suspect this is the issue. The new added function is showing lowercase t while other older functions are having upper case T. Any idea about what I might be doing wrong?

ashish
  • 813
  • 3
  • 10
  • 18

1 Answers1

54

Any idea about what I might be doing wrong?

The t function is indeed local to the library. This could happen due to a number or reasons. The most likely ones are:

  1. You declared the function static, or
  2. You compiled the library with -fvisibility=hidden and did not have __attribute__((visibility("default"))) on the function, or
  3. You linked this library with a linker version script (i.e. with --version-script=libfoo.version flag) that hides all functions, except those which are explicitly exported, and you didn't add your function to that list.

    See this example of using --version-script to limit symbol visibility.
piet.t
  • 11,718
  • 21
  • 43
  • 52
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • The third point was the issue. Fuse has some version script and explicitly export the functions. – ashish May 31 '16 at 06:20
  • But why does a static/local function show in the symbol list? I supposed that only a function which can be called be external environment should show in the symbol list? – xnervwang Mar 20 '23 at 17:36
  • @xnervwang " I supposed that only a function which can be called be external environment should show in the symbol list?" -- you supposed wrong. On UNIX local symbols are included by default in the symbol table to ease debugging. – Employed Russian Mar 20 '23 at 18:11