What does the `cc` option `-ldl` do in the following command?
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 to
dlopen'
dynamiclinktest.c:(.text+0x83): undefined reference to dlsym'
dynamiclinktest.c:(.text+0x109): undefined reference to
dlclose'
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
).
精彩评论