Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.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
MSVC 2015/libcurl/unresolved externals\u curl\u easy_init@0等_C_Visual C++_Dll_Libcurl_Unresolved External - Fatal编程技术网

MSVC 2015/libcurl/unresolved externals\u curl\u easy_init@0等

MSVC 2015/libcurl/unresolved externals\u curl\u easy_init@0等,c,visual-c++,dll,libcurl,unresolved-external,C,Visual C++,Dll,Libcurl,Unresolved External,我在编译一个使用libcurl静态版本的DLL时感到很笨拙。我将以下三个函数作为未解析的外部函数: 1>curl.obj : error LNK2001: unresolved external symbol _curl_easy_init@0 1>curl.obj : error LNK2001: unresolved external symbol _curl_easy_perform@4 1>curl.obj : error LNK2001: unresolved ext

我在编译一个使用libcurl静态版本的DLL时感到很笨拙。我将以下三个函数作为未解析的外部函数:

1>curl.obj : error LNK2001: unresolved external symbol _curl_easy_init@0
1>curl.obj : error LNK2001: unresolved external symbol _curl_easy_perform@4
1>curl.obj : error LNK2001: unresolved external symbol _curl_easy_cleanup@4
以下是链接器操作的剪报:

1>Searching libraries
1>      Searching D:\develop\rm-asset\c-code\libs\libcurl.lib:
1>        Found _curl_easy_setopt
1>          Referenced in curl.obj
1>          Loaded libcurl.lib(easy.obj)
1>        Found _curl_slist_free_all
1>          Referenced in libcurl.lib(easy.obj)
1>          Loaded libcurl.lib(slist.obj)
因此,我的代码使用curl\u easy\u setopt(…),它不会产生任何问题,并且与我使用curl\u easy\u init(…)的区域相同

查看libcurl.lib和dumpbin.exe中的符号,我看到:

SECTION HEADER #B
.text$mn name
       0 physical address
       0 virtual address
      3D size of raw data
    5D25 file pointer to raw data (00005D25 to 00005D61)
    5D62 file pointer to relocation table
       0 file pointer to line numbers
       3 number of relocations
       0 number of line numbers
60501020 flags
         Code
         COMDAT; sym= _curl_easy_init
         16 byte align
         Execute Read
哪个IMO显示符号os包含。至少它看起来与curl_easy_setopt非常相似:

SECTION HEADER #17
.text$mn name
       0 physical address
       0 virtual address
      23 size of raw data
    7245 file pointer to raw data (00007245 to 00007267)
    7268 file pointer to relocation table
       0 file pointer to line numbers
       1 number of relocations
       0 number of line numbers
60501020 flags
         Code
         COMDAT; sym= _curl_easy_setopt
         16 byte align
         Execute Read
这是使用libcurl的应用程序的编译器命令行:

    /GS /debug:expr-source-pos /analyze /W3 /Zc:wchar_t /I"d:\develop\rm-
asset\c-code\include" /I"D:\develop\rm-asset\c-code\extensions\qq-pun-mel-l\src"
 /O3 /Fd"R_Extended_Aliased\vc140.pdb" /fp:precise /fp:extended /D 
"REAL_T_EXTENDED" /D "_HAVE_SQLITE_CONFIG_H" /D "SQLITE_ENABLE_REDEF_IO=1" /D 
"SQLITE_ENABLE_CEROD=1" /D "SQLITE_DLL=1" /D "SQLITE_HAS_CODEC=1" /D 
"BUILDING_DLL" /D "R2" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D 
"SAPHIRIONDLL_EXPORTS" /D "ZLIB_WINAPI" /D "NDEBUG" /D "CURL_STATICLIB" /D"USE_WINDOWS_SSPI" /D "USE_SCHANNEL" /D "USE_WIN32_IDN" /D "WANT_IDN_PROTOTYPES" 
/D "_WINDLL" /D "_UNICODE" /D "UNICODE" /D "SQLITE_ENABLE_SESSION" /D 
"SQLITE_ENABLE_PREUPDATE_HOOK" /Zc:forScope /Gz /MT /Fa"R_Extended_Aliased\" 
/EHsc /nologo /Fo"R_Extended_Aliased\" /Qprof-dir "R_Extended_Aliased\" /Ot 
/Fp"R_Extended_Aliased\saphirion.pch" 

所以。。。我真的很困惑为什么这三个函数不能被解决。有什么想法要检查什么或如何进一步调查吗?

结果是呼叫约定。因此,请确保所有使用libcurl的部分都使用u cdecl调用约定。

如果静态链接到curl,我认为还必须为所有使用curl的代码定义curl u STATICLIB宏-请参见我这样做,很抱歉发布了错误的命令行。修正了。好的,我再往前一点。问题在于不同的调用约定。我的DLL使用stdcall,libcurl使用cdecl。当我试图用u stdcall编译libcurl时,我不得不更改一些函数签名以保持u cdecl。但后来我的测试程序崩溃了。。。知道为什么libcurl没有在Windows上使用stdcall吗?如何使用stdcall?