Using dlsym and adding -ldl to flags

I am trying to write a C program that uses dlysm, and I keep getting the undefined link to dlysm. I think I need to set the flags -ldl, but I don’t know how to do this.

I am very new to Linux and setting variables. If this is what I need to do, can someone help me with commands?

+3
source share
2 answers

-l Library parameters are used during connection.

If you compile only one source file ( gcc -o program program.c), then you both compile and link at a time. Just add -ldl.

(*.o), , -ldl (ld).

. man ld man cc

+3

-ldl .

:

gcc myprog.c -o app -ldl
+1

Source: https://habr.com/ru/post/1699394/


All Articles