Reputation: 655
I am getting this:
./ListBench: symbol lookup error: /usr/lib/libfoo.so: undefined symbol: memset, version GLIBC_2.2.5
Why is memset undefined in libc.so?
# ldd /usr/lib/foo.so
linux-vdso.so.1 => (0x00007fff167ff000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2f907eb000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f2f905e3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2f903c6000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2f90d86000)
# nm /lib/x86_64-linux-gnu/libc.so.6 | grep memset
nm: /lib/x86_64-linux-gnu/libc.so.6: no symbols
# objdump -T /lib/x86_64-linux-gnu/libc.so.6 | grep memset
00000000000904e0 g DF .text 0000000000000066 GLIBC_2.2.5 wmemset
00000000000f0620 g DF .text 0000000000000017 GLIBC_2.4 __wmemset_chk
0000000000083690 g iD .text 0000000000000029 GLIBC_2.2.5 memset
00000000000ecec0 g iD .text 0000000000000029 GLIBC_2.3.4 __memset_chk
# ldd --version
ldd (Debian EGLIBC 2.13-38) 2.13
foo.so is compiled using
gcc -shared -g -std=gnu99 -pedantic -fPIC -Wall -Wno-unused -fno-strict-aliasing -o libfoo.so sync.o ksnap.o time_util.o bitmap.o -lc -pthread -lrt;
Upvotes: 0
Views: 5255
Reputation: 655
The problem was a wrong order of linking options (-lfoo had to be last). Reordering them solved the problem.
Upvotes: 1
Reputation: 1
look for dynamic symbols, e.g.
nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep memset
00000000000fb210 i __memset_chk
00000000000fe910 T __wmemset_chk
0000000000086c30 i memset
000000000009cb00 T wmemset
and quite often (depending upon optimization level and compiler used when compiling your /usr/lib/foo.so
shared object) memset
could either be inlined or magically compiled as __builtin_memset
(see other builtins of GCC). On my Debian/Sid/x86-64 memset
is a macro in /usr/include/bits/string.h
included from <string.h>
Check carefully that you have indeed #include<string.h>
in every C source file calling memset
... Don't forget to always pass -Wall
to gcc
(it would warn if you forgot the inclusion)...
Upvotes: 1