Symbol lookup error: undefined symbol atexit (linux/C)
I get the error Symbol lookup error: undefined symbol atexit (linux/C)
when I try to run my program. atexit()
should be defined in <stdlib.h>.
Is there anything I could add to the -l
option when I compile it with gcc? Or anything else I could do? This is in C.
I am trying to write a shared object where I call atexit
once. I also define the corresponding function like explained.
$ LD_PRELOAD=mymal.so /bin/ls
/bin/ls: symbol lookup error: ./mymal.so: undefined symbol: atexit
I don't get a error after compilation, just when I try to execute it.
I build the shared library with the commands (source):
gcc -fPIC -c -ldl mymal.c
开发者_如何学JAVAld -shared -soname mymal.so.1 -o mymal.so -lc mymal.o
solved: it worked with g++
instead of gcc
.
The function is called atexit
, not Atexit
.
精彩评论