gpt4 book ai didi

c++ - 无法将 libcurl 链接到我正在进行的项目

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:44:11 55 4
gpt4 key购买 nike

我有一个作为客户端程序启动的项目。后来我决定实现一些客户端到服务器的通信来制作一种登录系统。我在纯 HTTP post 请求中开发了它并且它有效。

最近我将我的服务器更新为 HTTPS,现在普通的 HTTP post 请求不再有效,而且由于我要通过网络传输敏感数据,我决定也在我的客户端上实现 SSL。我见过的替代方案包括带有 OpenSSL/WolfSSL 的 Libcurl 或带有 OpenSSL 的 Boost。我决定继续使用 Libcurl。

所以现在,我已经尝试下载一些预编译的 libcurl 构建等,但没有成功链接到它,给我一些这样的错误:

1>Attacker.obj : error LNK2001: unresolved external symbol __imp__PostMessageW@16
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__EnableWindow@8
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__GetWindowTextLengthA@4
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__GetOpenFileNameA@4
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__GetClientRect@8
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__SendMessageA@16
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__SetWindowTextA@8
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__GetWindowTextA@12
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__RedrawWindow@16
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__ShowWindow@8
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__SetWindowPos@28
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__DestroyWindow@4
1>FormVarClass.obj : error LNK2001: unresolved external symbol __imp__CreateSolidBrush@4
1>FormVarClass.obj : error LNK2001: unresolved external symbol __imp__CreatePen@12
1>FormVarClass.obj : error LNK2001: unresolved external symbol __imp__CreateFontW@56
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__SetParent@8
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__MoveWindow@24
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__AttachThreadInput@12
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__GetWindowLongA@8
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__SetWindowLongA@12
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__GetWindowRect@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__EndPaint@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__BeginPaint@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__PostQuitMessage@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__LoadCursorW@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__LoadIconW@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__TranslateMessage@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
1>GUI.obj : error LNK2001: unresolved external symbol __imp__IsDialogMessageW@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__DispatchMessageW@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__RegisterClassExW@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__CloseWindow@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__DefWindowProcW@16
1>GUI.obj : error LNK2001: unresolved external symbol __imp__GetMessageW@16
1>Main.obj : error LNK2001: unresolved external symbol __imp__SHGetFolderPathA@20
1>Mem.obj : error LNK2001: unresolved external symbol __imp__EnumWindows@8
1>Mem.obj : error LNK2001: unresolved external symbol __imp__IsWindowVisible@4
1>Mem.obj : error LNK2001: unresolved external symbol __imp__GetWindow@8
1>Mem.obj : error LNK2001: unresolved external symbol __imp__GetWindowThreadProcessId@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__InvalidateRect@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__ExtTextOutW@32
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__FillRgn@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__RoundRect@28
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__CombineRgn@16
1>Overrides.obj : error LNK2001: unresolved external symbol enter code here__imp__ScrollWindow@20
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetScrollPos@16
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__DeleteObject@4
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetBkColor@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__EnableScrollBar@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetCursor@4
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetBkMode@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetTextColor@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__GetSysColor@4
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__CreateRectRgn@16
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__CreateRoundRectRgn@24
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__DrawTextA@20
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SendMessageW@16
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__UnionRect@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__FillRect@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__InflateRect@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SelectObject@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetScrollInfo@16
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__GetWindowTextLengthW@4
1>Window.obj : error LNK2001: unresolved external symbol __imp__TrackMouseEvent@4
1>libcurl.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp__strerror
1>libcurl.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurl.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurl.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurl.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurl.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp____sys_nerr
1>libcurl.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp__fgets
1>libcurl.lib(netrc.obj) : error LNK2001: unresolved external symbol __imp__fgets
1>libcurl.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp__fputs
1>libcurl.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(rtsp.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(http_proxy.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(parsedate.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(imap.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(hostip.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(url.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(http.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(tftp.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(digest.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(ftplistparser.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(vtls.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(http.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(vtls.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurl.lib(url.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurl.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurl.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurl.lib(warnless.obj) : error LNK2001: unresolved external symbol __imp__read
1>OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp__read
1>libcurl.lib(warnless.obj) : error LNK2001: unresolved external symbol __imp__write
1>OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp__write
1>libcurl.lib(curl_threads.obj) : error LNK2001: unresolved external symbol __imp___beginthreadex
1>libcurl.lib(file.obj) : error LNK2001: unresolved external symbol __imp__close
1>OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp__close
1>libcurl.lib(file.obj) : error LNK2001: unresolved external symbol __imp__open
1>OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp__open
1>libcurl.lib(file.obj) : error LNK2001: unresolved external symbol __imp___fstat64
1>libcurl.lib(smb.obj) : error LNK2001: unresolved external symbol __imp___getpid
1>libcurl.lib(system_win32.obj) : error LNK2001: unresolved external symbol __imp___mbspbrk
1>libcurl.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp__feof
1>libcurl.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp__ferror
1>libcurl.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp___stat64

然后我尝试自己构建 Libcurl,并从他们的站点下载最新版本并使用“LIB Debug - LIB OpenSSL”构建选项从头开始构建它。链接到 OpenSSL 库并指向它们的包含目录,它编译并为我构建了 libcurl.lib 文件。

因此,在我的主项目中,现在我包含了 libcurl 包含目录和 openssl 包含目录,然后我链接了这两个相应的 Lib 文件夹,所以它应该没问题。

http://prntscr.com/eg389b .

然后在链接器的附加依赖项中,我将其设置为“crypt32.lib;ws2_32.lib;wldap32.lib;libeay32.lib;ssleay32.lib;libcurld.lib”。这是我发现应该完成的所有步骤,但即使那样我也遇到了完全相同的 Unresolved external symbol 错误。

PS:从头开始不是一种选择。

PS2:为了可移植性,除了 VC++ redist 之外,我更愿意自己构建我的程序而不需要外部 DLL。

编辑 1

现在,使用此处描述的方法 LibCurl - Release Static Lib linking problems我已经大大减少了未解析的外部符号的数量,并将它们追溯到 libcurld.lib、OLDNAMES.lib 和 MSVCRTD.lib。所以只有这三个出现并烦扰我。

1>libcurld.lib(strerror.obj) : error LNK2019: unresolved external symbol __imp__strerror referenced in function _Curl_strerror
1>libcurld.lib(curl_gethostname.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(rand.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(http_ntlm.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(http_proxy.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(ntlm.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(pingpong.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(openssl.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(imap.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(rtsp.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(conncache.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(warnless.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(curl_addrinfo.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(inet_ntop.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(connect.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(http.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(wildcard.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(hostip.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(vtls.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(sendf.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(slist.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(multi.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(asyn-thread.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(strerror.obj) : error LNK2019: unresolved external symbol __imp____sys_nerr referenced in function _Curl_strerror
1>libcurld.lib(cookie.obj) : error LNK2019: unresolved external symbol __imp__fgets referenced in function _get_line
1>libcurld.lib(netrc.obj) : error LNK2001: unresolved external symbol __imp__fgets
1>libcurld.lib(cookie.obj) : error LNK2019: unresolved external symbol __imp__fputs referenced in function _cookie_output
1>libcurld.lib(telnet.obj) : error LNK2019: unresolved external symbol __imp____stdio_common_vsscanf referenced in function _sendsuboption
1>libcurld.lib(rtsp.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(http_proxy.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(http.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(parsedate.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(imap.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(hostip.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__strstr referenced in function _ftp_statemach_act
1>libcurld.lib(tftp.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(digest.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(ftplistparser.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(vtls.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(http.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(vtls.obj) : error LNK2019: unresolved external symbol __imp__fread referenced in function _Curl_pin_peer_pubkey
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurld.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurld.lib(warnless.obj) : error LNK2019: unresolved external symbol __imp__read referenced in function _curlx_read
1>OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp__read
1>libcurld.lib(warnless.obj) : error LNK2019: unresolved external symbol __imp__write referenced in function _curlx_write
1>OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp__write
1>libcurld.lib(curl_threads.obj) : error LNK2019: unresolved external symbol __imp___beginthreadex referenced in function _Curl_thread_create
1>libcurld.lib(file.obj) : error LNK2019: unresolved external symbol __imp__close referenced in function _file_done
1>OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp__close
1>libcurld.lib(file.obj) : error LNK2019: unresolved external symbol __imp__open referenced in function _file_connect
1>OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp__open
1>libcurld.lib(file.obj) : error LNK2019: unresolved external symbol __imp___fstat64 referenced in function _file_do
1>libcurld.lib(smb.obj) : error LNK2019: unresolved external symbol __imp___getpid referenced in function _smb_format_message
1>libcurld.lib(system_win32.obj) : error LNK2019: unresolved external symbol __imp___mbspbrk referenced in function __tcspbrk
1>libcurld.lib(formdata.obj) : error LNK2019: unresolved external symbol __imp__feof referenced in function _Curl_getformdata
1>libcurld.lib(formdata.obj) : error LNK2019: unresolved external symbol __imp__ferror referenced in function _Curl_getformdata
1>libcurld.lib(formdata.obj) : error LNK2019: unresolved external symbol __imp___stat64 referenced in function _AddFormData
1>MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4

最佳答案

您必须将 libcurl 编译选项更改为 Mtd/Mt。

关于c++ - 无法将 libcurl 链接到我正在进行的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42602287/

55 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com