Windows链接到libcurl_a.lib

时间:2017-10-05 12:29:09

标签: c windows libcurl cl cl.exe

我按照将curcurl构建为curl / winbuild目录中的静态库的说明构建了libcurl。它吐出libcurl_a.lib.h个文件的集合,我将其移动到我立即添加到PATH的文件夹中。然后我尝试使用命令

构建我的程序
cl (*my source files*) /IC:/PATH_addon/include libcurl_a.lib Ws2_32.lib Wldap32.lib /DCURL_STATICLIB /link /LIBPATH:C:/PATH_addon/lib 

注意:

  • 我正在从命令行构建代码,因为代码没有写在IDE中,也没有写在这台机器上

  • C:/ PATH_addon /是一个文件夹,我将所有需要链接的东西转储到路径中(它链接到我的路径),这样我就不会污染默认路径或我的system32文件夹

然而,当我运行命令时,它告诉我有12个未解析的符号:

libcurl_a.lib(tftp.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(hostip.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(http.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(curl_sspi.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(warnless.obj) : error LNK2019: unresolved external symbol __imp__read referenced in function _curlx_read
OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp__read
libcurl_a.lib(warnless.obj) : error LNK2019: unresolved external symbol __imp__write referenced in function _curlx_write
OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp__write
libcurl_a.lib(parsedate.obj) : error LNK2019: unresolved external symbol __imp___gmtime64 referenced in function _Curl_gmtime
libcurl_a.lib(strerror.obj) : error LNK2019: unresolved external symbol __imp__strerror referenced in function _Curl_strerror
libcurl_a.lib(curl_threads.obj) : error LNK2019: unresolved external symbol __imp___beginthreadex referenced in function _Curl_thread_create
libcurl_a.lib(smb.obj) : error LNK2019: unresolved external symbol __imp___getpid referenced in function _smb_format_message
libcurl_a.lib(file.obj) : error LNK2019: unresolved external symbol __imp__close referenced in function _file_done
OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp__close
libcurl_a.lib(file.obj) : error LNK2019: unresolved external symbol __imp__open referenced in function _file_connect
OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp__open
libcurl_a.lib(mime.obj) : error LNK2019: unresolved external symbol __imp__access referenced in function _curl_mime_filedata
OLDNAMES.lib(access.obi) : error LNK2001: unresolved external symbol __imp__access
MSVCRT.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4

为什么不能解析这些符号,有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:0)

解决方案(部分归功于令人难以置信的@Hans Passant):

添加/NODEFAULTLIB:LIBCMT标志解决了问题并允许成功编译和执行。