无法使libcurl库与C程序一起编译

时间:2019-11-21 06:46:36

标签: c curl linker network-programming libcurl

我很抱歉以前是否曾问过这种问题,但是我对此失去了理智,我对将库与C结合使用并尝试弄清楚如何使用libcurl编译C程序还是比较陌生。 C程序实际上只是libcurl网站https://curl.haxx.se/libcurl/c/https.html上的示例代码。到目前为止,我已经尝试使用 gcc -I{directory of /curl-7.67.0-win64-mingw/include} -L{directory of /curl-7.67.0-win64-mingw/lib} -llibcurl.a curl.c 以及libcurl名称的变体,例如libcurl,不带.a,也只有curl.acurl。它不断给我以下错误:

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WILLOC~1\AppData\Local\Temp\ccMzPQvE.o:curl.c:(.text+0xca): undefined reference to `_imp__curl_global_init'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WILLOC~1\AppData\Local\Temp\ccMzPQvE.o:curl.c:(.text+0xd1): undefined reference to `_imp__curl_easy_init'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WILLOC~1\AppData\Local\Temp\ccMzPQvE.o:curl.c:(.text+0x102): undefined reference to `_imp__curl_easy_setopt'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WILLOC~1\AppData\Local\Temp\ccMzPQvE.o:curl.c:(.text+0x110): undefined reference to `_imp__curl_easy_perform'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WILLOC~1\AppData\Local\Temp\ccMzPQvE.o:curl.c:(.text+0x129): undefined reference to `_imp__curl_easy_strerror'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WILLOC~1\AppData\Local\Temp\ccMzPQvE.o:curl.c:(.text+0x153): undefined reference to `_imp__curl_easy_cleanup'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\WILLOC~1\AppData\Local\Temp\ccMzPQvE.o:curl.c:(.text+0x15a): undefined reference to `_imp__curl_global_cleanup'
collect2.exe: error: ld returned 1 exit status

据我了解,我应该能够使用-L和-l链接.a文件。我究竟做错了什么?是不是我没有libcurl依赖的外部依赖项?

0 个答案:

没有答案