How do I solve these libcurl linking errors?(如何解决这些 libcurl 链接错误?)
问题描述
[Administrator@windows ~]$ g++ client.cpp -lcurl -o client.exe
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0x23): undefined reference to `_imp__curl_global_init'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0x5f): undefined reference to `_imp__curl_formadd'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0x9b): undefined reference to `_imp__curl_formadd'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0xa2): undefined reference to `_imp__curl_easy_init'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0xc8): undefined reference to `_imp__curl_easy_setopt'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0xe4): undefined reference to `_imp__curl_easy_setopt'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0xf1): undefined reference to `_imp__curl_easy_perform'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0x101): undefined reference to `_imp__curl_easy_cleanup'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0x10e): undefined reference to `_imp__curl_formfree'
C:DOCUME~1ADMINI~1LOCALS~1TempccKXFUtC.o:client.cpp:(.text+0x11b): undefined reference to `_imp__curl_slist_free_all'
collect2: ld returned 1 exit status
我在 linux 上没有这个问题,所以我不知道为什么会在 windows 上发生这种情况.我已经用 google 搜索过了,除了邮件列表存档之外没有找到任何东西,并回复说google it".
I don't have this problem on linux so I don't know why this happens on windows. I googled it already and didn't find anything except mailing list archives with the same question and reply saying "google it".
我正在使用 mingw.我在构建 libcurl 时确实收到了一些链接器警告,但它们似乎与 ssl 相关,而且我不知道这是否很重要,因为它构建时没有错误.
I'm using mingw. I did get some linker warnings when I built libcurl but they seemed to be ssl related and I don't know if it's a big deal because it built without errors.
*** Warning: linker path does not have real file for library -lssl.
*** I have the capability to make that library automatically link in when
*** you link to this library. But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libssl and none of the candidates passed a file format test
*** using a file magic. Last file checked: /ssl/lib/libssl.a
*** Warning: linker path does not have real file for library -lcrypto.
*** I have the capability to make that library automatically link in when
*** you link to this library. But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libcrypto and none of the candidates passed a file format test
*** using a file magic. Last file checked: /ssl/lib/libcrypto.a
*** Warning: linker path does not have real file for library -lz.
*** I have the capability to make that library automatically link in when
*** you link to this library. But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libz and none of the candidates passed a file format test
*** using a file magic. Last file checked: /mingw/lib//libz.a
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.
*** Since this library must not contain undefined symbols,
*** because either the platform does not support them or
*** it was explicitly requested with -no-undefined,
*** libtool will only create a static version of it.
推荐答案
通过添加选项 -lcurl.dll
,我能够避免 windows (mingw win32) 上的这些 curl 链接错误.-DCURL_STATICLIB
在我的情况下不需要.
I was able to avoid these curl linking errors on windows (mingw win32) by adding option -lcurl.dll
. -DCURL_STATICLIB
was not needed in my case.
我的构建在 mingw/lib 文件夹中有两个 libcurl 文件:libcurl.a 和 libcurl.dll.a
My build has two libcurl files in mingw/lib folder: libcurl.a and libcurl.dll.a
这篇关于如何解决这些 libcurl 链接错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何解决这些 libcurl 链接错误?
基础教程推荐
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 从 std::cin 读取密码 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01