Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ libcurl静态链接-对`\u imp的未定义引用__WSAIoctl@36';_C++_Mingw_Libcurl - Fatal编程技术网

C++ libcurl静态链接-对`\u imp的未定义引用__WSAIoctl@36';

C++ libcurl静态链接-对`\u imp的未定义引用__WSAIoctl@36';,c++,mingw,libcurl,C++,Mingw,Libcurl,我试图在Windows上的代码块中静态链接libcurl 我用“mingw32 make mingw32”编译了libcurl,并链接了生成的库libcurl.a和libcurldll.a。我在ere上看到另一篇帖子,建议解决方案是添加选项-lwldap32,但这没有什么区别:/ 我错过了什么 编辑:以下是成功完成的第一个编译命令的示例: mingw32-g++.exe -Wall -pipe -mthreads -std=gnu++14 -D__GNUWIN32__ -D__WXMSW__ -

我试图在Windows上的代码块中静态链接libcurl

我用“mingw32 make mingw32”编译了libcurl,并链接了生成的库libcurl.a和libcurldll.a。我在ere上看到另一篇帖子,建议解决方案是添加选项-lwldap32,但这没有什么区别:/

我错过了什么

编辑:以下是成功完成的第一个编译命令的示例:

mingw32-g++.exe -Wall -pipe -mthreads -std=gnu++14 -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -O2 -DCURL_STATICLIB -IE:\plus\libs\wxWidgets\include -IE:\plus\libs\curl-7.43.0\include -IE:\plus\libs\wxWidgets\lib\gcc_lib\mswu -c E:\plus\projects\hlr\hlrMain.cpp -o obj\Release\hlrMain.o
E:\plus\projects\hlr\hlrMain.cpp:165:1: warning: 'virtual bool wxEvtHandler::TryValidator(wxEvent&)' is deprecated [-Wdeprecated-declarations]
 }
 ^
In file included from E:\plus\libs\wxWidgets\include/wx/menu.h:14:0,
                 from E:\plus\projects\hlr\hlrMain.h:14,
                 from E:\plus\projects\hlr\hlrMain.cpp:10:
E:\plus\libs\wxWidgets\include/wx/event.h:3683:22: note: declared here
         virtual bool TryValidator(wxEvent& WXUNUSED(event)), return false; )
                      ^
E:\plus\libs\wxWidgets\include/wx/defs.h:615:43: note: in definition of macro 'wxDEPRECATED'
 #define wxDEPRECATED(x) wxDEPRECATED_DECL x
                                           ^
E:\plus\libs\wxWidgets\include/wx/event.h:3682:5: note: in expansion of macro 'wxDEPRECATED_BUT_USED_INTERNALLY_INLINE'
     wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
     ^
E:\plus\projects\hlr\hlrMain.cpp:165:1: warning: 'virtual bool wxEvtHandler::TryParent(wxEvent&)' is deprecated [-Wdeprecated-declarations]
 }
链接到完整输出,并在此处显示大量警告:

编译失败:

mingw32-g++.exe -LE:\plus\libs\wxWidgets\lib\gcc_lib -o bin\Release\hlr.exe obj\Release\hlrApp.o obj\Release\hlrMain.o  obj\Release\resource.res -s -lwldap32 -mthreads  -lwxmsw30u -lwxpng -lwxjpeg -lwxtiff -lwxzlib E:\plus\libs\curl-7.43.0\lib\libcurl.a E:\plus\libs\curl-7.43.0\lib\libcurldll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
E:\plus\libs\curl-7.43.0\lib\libcurl.a(connect.o):(.text+0xbda): undefined reference to `_imp__WSAIoctl@36'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x145): undefined reference to `_imp__ldap_err2string'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x187): undefined reference to `_imp__ldap_msgfree'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x1b4): undefined reference to `_imp__ldap_unbind_s'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x41f): undefined reference to `_imp__ldap_set_option'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x444): undefined reference to `_imp__ldap_init'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x47b): undefined reference to `_imp__ldap_simple_bind_s'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x4f1): undefined reference to `_imp__ldap_err2string'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x5a9): undefined reference to `_imp__ldap_search_s'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x5c2): undefined reference to `_imp__ldap_err2string'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x5f1): undefined reference to `_imp__ldap_first_entry'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x62c): undefined reference to `_imp__ldap_get_dn'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x6cc): undefined reference to `_imp__ldap_memfree'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x6e9): undefined reference to `_imp__ldap_first_attribute'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x71e): undefined reference to `_imp__ldap_get_values_len'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x911): undefined reference to `_imp__ldap_value_free_len'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x91e): undefined reference to `_imp__ldap_memfree'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x93b): undefined reference to `_imp__ber_free'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x983): undefined reference to `_imp__ldap_value_free_len'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x990): undefined reference to `_imp__ldap_memfree'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0x9ef): undefined reference to `_imp__ldap_next_attribute'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0xa14): undefined reference to `_imp__ber_free'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0xa29): undefined reference to `_imp__ldap_next_entry'
E:\plus\libs\curl-7.43.0\lib\libcurl.a(ldap.o):(.text+0xa69): undefined reference to `_imp__ldap_memfree'

Curl依赖于OpenSSL。确保你已经链接了它。
_imp_uuwsaioctl是“Ws2.lib”(Ws2_32.lib)的一部分,标题为“winsock2.h”。尝试确保此引用在您的项目中得到解决。

对于其他有此问题的人,我需要添加ws2_32库,方法是在代码::块中添加链接器设置->链接库,使用完整文件名libws2_32.a

由于某些原因,在网上其他地方建议添加-lws2_32是不够的

编译命令现在是:

mingw32-g++.exe -LE:\plus\libs\wxWidgets\lib\gcc_lib -o bin\Release\hlr.exe obj\Release\hlrApp.o obj\Release\hlrMain.o  obj\Release\resource.res -s -mthreads  -lwxmsw30u -lwxpng -lwxjpeg -lwxtiff -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 E:\plus\libs\curl-7.43.0\lib\libcurl.a E:\plus\compilers\MinGW\i686-w64-mingw32\lib\libws2_32.a E:\plus\compilers\MinGW\i686-w64-mingw32\lib\libwldap32.a -mwindows

我看不出在编译步骤中添加头路径的位置。您是否缺少了
-L/path/to/libcurl/headers/include
?第一个编译命令中可能有重复的内容,我成功地忽略了这一点:您需要缩减所有内容并将其包含在您的帖子中,而不是包含到pastebin的链接。我不知道我可以删除pastebin链接的哪些部分,我认为这些都不重要,但霍尼班奇问起了。据我所知,其中一个警告可能是我问题的原因。不过我会在其中的一个例子中进行编辑。我已经根据刚才添加的答案对问题进行了排序,但我回去也尝试了你的解决方案,因为我真的不明白为什么我的修复会产生这样的效果,但在包含winsock2时,我仍然会遇到相同的错误。我敢打赌,问题确实在于
ws2_32
库需要在
libcurl
库之后的命令行上出现。GCC的链接器对库的排序很敏感(依赖其他库的库通常需要在它们依赖的库之前进行排序)。请注意,如果是这种情况,那么答案是“可能重复”帖子的“通用”答案(副本有指向的链接)。尽管这个通用答案很长,但还是值得阅读和理解,因为核心编译器工具工作原理的基础知识值得了解(或至少了解)。我知道顺序很重要,尽管我不完全理解所需的顺序,但是,如果添加一个建议的库不能解决问题,我总是尝试从代码块中复制命令,并在命令提示符中运行它,将有问题的库移到最后,在这里没有任何区别。下次遇到类似问题时,我将阅读详细的答案。将来使用gnu工具时可能有助于解决链接器问题的另一个技巧是使用
-Wl,--verbose
选项,该选项告诉链接器转储有关正在搜索哪些库以及何时搜索这些库的信息。