[英]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.当我尝试运行我的程序时,我收到错误
Symbol lookup error: undefined symbol atexit (linux/C)
。 atexit()
should be defined in <stdlib.h>.
atexit()
应该在<stdlib.h>.
Is there anything I could add to the -l
option when I compile it with gcc?当我用 gcc 编译它时,有什么可以添加到
-l
选项的吗? Or anything else I could do?或者我还能做什么? This is in C.
这是在 C 中。
I am trying to write a shared object where I call atexit
once.我正在尝试编写一个共享的 object ,我在其中调用了
atexit
一次。 I also define the corresponding function like explained .我还像解释的那样定义了相应的 function。
$ 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 ):我使用命令( source )构建共享库:
gcc -fPIC -c -ldl mymal.c
ld -shared -soname mymal.so.1 -o mymal.so -lc mymal.o
solved: it worked with g++
instead of gcc
.已解决:它与
g++
而不是gcc
一起使用。
The function is called atexit
, not Atexit
. function 称为
atexit
,而不是Atexit
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.