How to fix C warning: implicit declaration of function 'dlsym'
Problem:
You have C code like
example.txt
dlsym(RTLD_NEXT, 'myfunc');
```c {filename="main.c"}
but when you try to compile it you see a warning message like
```plaintext {filename="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');
Solution
Add
main_fixed.c
#include <dlfcn.h>
at the top of the source file where the error occured. This will include both dlopen
, dlsym
and related definitions like 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