• <bdo id='zWCGr'></bdo><ul id='zWCGr'></ul>

    <legend id='zWCGr'><style id='zWCGr'><dir id='zWCGr'><q id='zWCGr'></q></dir></style></legend>
  1. <small id='zWCGr'></small><noframes id='zWCGr'>

    <i id='zWCGr'><tr id='zWCGr'><dt id='zWCGr'><q id='zWCGr'><span id='zWCGr'><b id='zWCGr'><form id='zWCGr'><ins id='zWCGr'></ins><ul id='zWCGr'></ul><sub id='zWCGr'></sub></form><legend id='zWCGr'></legend><bdo id='zWCGr'><pre id='zWCGr'><center id='zWCGr'></center></pre></bdo></b><th id='zWCGr'></th></span></q></dt></tr></i><div id='zWCGr'><tfoot id='zWCGr'></tfoot><dl id='zWCGr'><fieldset id='zWCGr'></fieldset></dl></div>

    1. <tfoot id='zWCGr'></tfoot>

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

      时间:2023-10-06

        <tbody id='SlKwo'></tbody>
      • <tfoot id='SlKwo'></tfoot>

        • <bdo id='SlKwo'></bdo><ul id='SlKwo'></ul>
            <legend id='SlKwo'><style id='SlKwo'><dir id='SlKwo'><q id='SlKwo'></q></dir></style></legend>

              <small id='SlKwo'></small><noframes id='SlKwo'>

              <i id='SlKwo'><tr id='SlKwo'><dt id='SlKwo'><q id='SlKwo'><span id='SlKwo'><b id='SlKwo'><form id='SlKwo'><ins id='SlKwo'></ins><ul id='SlKwo'></ul><sub id='SlKwo'></sub></form><legend id='SlKwo'></legend><bdo id='SlKwo'><pre id='SlKwo'><center id='SlKwo'></center></pre></bdo></b><th id='SlKwo'></th></span></q></dt></tr></i><div id='SlKwo'><tfoot id='SlKwo'></tfoot><dl id='SlKwo'><fieldset id='SlKwo'></fieldset></dl></div>

                本文介绍了如何在 MSVC 中使用使用 MingW 编译的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我用 MingW/MSYS 编译了几个库……生成的静态库总是 .a 文件.当我尝试将库与 MSVC 项目链接时,Visual Studio 抛出未解析的外部符号"......这意味着 .a 静态库与 MS C++ 链接器不兼容.我认为它必须转换为兼容 MSVC 的 .lib 文件.

                I have compiled several libraries with MingW/MSYS... the generated static libraries are always .a files. When I try to link the library with a MSVC project, Visual Studio throws 'unresolved external symbols' ... It means that the .a static library is incompatible with MS C++ Linker. I presume it has to be converted to a MSVC compatible .lib file.

                .a 和 .lib 只是 .o 或 .obj 文件的 AR 档案,那么有什么方法可以在 MSVC 项目中使用 MingW 编译的库?或者我是否必须仅在一个编译器/链接器中编译/链接所有内容 - 仅限 MSVC/仅限 MingW?据说 MingW 编译器与 MSVC 兼容.

                Either .a and .lib are just AR archives of .o or .obj files, so is there any way how to use MingW compiled libs in a MSVC project? Or do I have to compile/link everything just in one compiler/linker - MSVC only/MingW only? The MingW compiler is said to be compatible with MSVC.

                我阅读了一些关于这个主题的帖子,但他们大多说将文件重命名为 .lib 应该可以解决问题,但不幸的是它对我不起作用.

                I read a few threads about this topic, but they mostly say that renaming the file to .lib should do the work, but it unfortunately doesn't work for me.

                我尝试链接的库是用 C 编写的.

                The libraries Im trying to link are written in C.

                MSVC 链接器抛出如下错误:

                MSVC Linker throws errors like:

                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
                

                ...还有 4 个相同的错误,这些错误涉及从我的应用中调用的其他函数.

                ... and 4 more same errors referring to other functions called from my app.

                感谢您的建议.

                推荐答案

                基于此错误,您发表评论:

                Based on this error you put in a comment:

                错误 LNK2019:未解析的外部符号int __cdeclopenssl_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

                尝试将 extern "C" 放在 openssl 的包含文件周围.例如:

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

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

                使用 extern "C"指示编译器函数使用的是 C 链接,而不是 C++,这将阻止它执行 name mangling 关于函数.所以它将在库中查找函数 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@.

                这篇关于如何在 MSVC 中使用使用 MingW 编译的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:/Ox 和/O2 编译器选项之间有什么区别? 下一篇:如何在 Microsoft Visual Studio C++ 中以 Windows XP 为目标

                相关文章

                最新文章

                <i id='QyZkv'><tr id='QyZkv'><dt id='QyZkv'><q id='QyZkv'><span id='QyZkv'><b id='QyZkv'><form id='QyZkv'><ins id='QyZkv'></ins><ul id='QyZkv'></ul><sub id='QyZkv'></sub></form><legend id='QyZkv'></legend><bdo id='QyZkv'><pre id='QyZkv'><center id='QyZkv'></center></pre></bdo></b><th id='QyZkv'></th></span></q></dt></tr></i><div id='QyZkv'><tfoot id='QyZkv'></tfoot><dl id='QyZkv'><fieldset id='QyZkv'></fieldset></dl></div>

                  <legend id='QyZkv'><style id='QyZkv'><dir id='QyZkv'><q id='QyZkv'></q></dir></style></legend>

                    <small id='QyZkv'></small><noframes id='QyZkv'>

                    • <bdo id='QyZkv'></bdo><ul id='QyZkv'></ul>
                    <tfoot id='QyZkv'></tfoot>