开发者

What does the `cc` option `-ldl` do in the following command?

开发者 https://www.devze.com 2023-01-15 06:39 出处:网络
during compilation of dynlinktest.c it gives following error: unipro@ubuguest:~$ cc dynamiclinktest.c -o dynamiclinktest

during compilation of dynlinktest.c it gives following error:

unipro@ubuguest:~$ cc dynamiclinktest.c -o dynamiclinktest /tmp/ccli8dp2.o: In function main': dynamiclinktest.c:(.text+0x53): undefined reference todlopen' dynamiclinktest.c:(.text+0x83): undefined reference to dlsym' dynamiclinktest.c:(.text+0x109): undefined reference todlclose' collect2: ld returned 1 exit status

after using cc dynlinktest.c -o dynlinktest -ldl it runs. i didn't get why it is neccessary using -ldl ?

edit1: leaving spac开发者_StackOverflowe before error.


-ldl includes the reference to the library that has the symbols for loading dynamic libraries (such as dlopen).

0

精彩评论

暂无评论...
验证码 换一张
取 消