且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在MSVC中使用MingW编译的库?

更新时间:2023-11-09 11:25:16

根据此错误,您输入注释:

Based on this error you put in a comment:


error LNK2019:unresolved external
symbolint __cdecl
openssl_call(struct ssl_State
*,int,int,int)(?openssl_call @@ YAHPAUssl_State @@ HHH @ Z)
在函数_main中引用MyAPP.obj
所有其他4个错误仅与
相同其他函数名称

error LNK2019: unresolved external symbol "int __cdecl openssl_call(struct ssl_State *,int,int,int)" (?openssl_call@@YAHPAUssl_State@@HHH@Z) referenced in function _main MyAPP.obj all other 4 errors are same only with other functions names

在你的include文件中放置 externC。例如:

Try putting extern "C" around your include files for openssl. For example:

extern "C" {
include "openssl.h"
}

使用 externC将指示编译器函数使用C链接,而不是C ++,这将阻止它执行名称修改。因此,它将在库中查找函数openssl_call,而不是?openssl_call @@ YAHPAUssl_State @@ HHH @。

using extern "C" will instruct the compiler that the functions are using C linkage, not C++, which will stop it from performing name mangling on the functions. So it will look for the function openssl_call in the library rather than ?openssl_call@@YAHPAUssl_State@@HHH@.