如何修复 C 警告:implicit declaration of function 'dlsym'
问题:
你有类似这样的 C 代码
main.c
dlsym(RTLD_NEXT, 'myfunc');但当你尝试编译它时,你看到类似这样的警告消息
dlsym_warning.txt
main.c: In function ‘main’:
main.c:3:5: warning: implicit declaration of function ‘dlsym’ [-Wimplicit-function-declaration]
dlsym(RTLD_NEXT, 'myfunc');解决方案
添加
main_fixed.c
#include <dlfcn.h>在错误发生的源文件顶部。这将包含 dlopen、dlsym 以及相关定义如 RTLD_NEXT。
Check out similar posts by category:
C/C++, GCC Errors
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow