How to use dlopen to find out if this library is in the system?

Example:

 Входные данне : libcrypt.so Выходные : Yes или No 
  • @NicolasChabanovsky why winapi? - aleksandr barakin
  • Yes, something has already forgotten. For some reason, it seemed to be a function from WinAPI. - Nicolas Chabanovsky

1 answer 1

look at a sample example from man dlopen .

like that:

 ### dlopentest.c #include <stdio.h> #include <dlfcn.h> void main() { char filename[20]; scanf ("%s", filename); if (dlopen (filename, RTLD_LAZY)) printf ("yes\n"); else printf ("no\n"); } 

collect:

 $ make dlopentest CFLAGS=-ldl cc -ldl dlopentest.c -o dlopentest 

check:

 $ echo libcrypt.so | ./dlopentest yes $ echo beliberda | ./dlopentest no