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

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

    2. <tfoot id='NtBpu'></tfoot>
        <bdo id='NtBpu'></bdo><ul id='NtBpu'></ul>

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

      How to use libraries compiled with MingW in MSVC?(如何在 MSVC 中使用使用 MingW 编译的库?)
          <bdo id='y07Qg'></bdo><ul id='y07Qg'></ul>

            <tbody id='y07Qg'></tbody>

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

            <tfoot id='y07Qg'></tfoot>
          1. <legend id='y07Qg'><style id='y07Qg'><dir id='y07Qg'><q id='y07Qg'></q></dir></style></legend>

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

              1. 本文介绍了如何在 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 编译的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)
                <i id='7L8jW'><tr id='7L8jW'><dt id='7L8jW'><q id='7L8jW'><span id='7L8jW'><b id='7L8jW'><form id='7L8jW'><ins id='7L8jW'></ins><ul id='7L8jW'></ul><sub id='7L8jW'></sub></form><legend id='7L8jW'></legend><bdo id='7L8jW'><pre id='7L8jW'><center id='7L8jW'></center></pre></bdo></b><th id='7L8jW'></th></span></q></dt></tr></i><div id='7L8jW'><tfoot id='7L8jW'></tfoot><dl id='7L8jW'><fieldset id='7L8jW'></fieldset></dl></div>

                  <tbody id='7L8jW'></tbody>
              2. <tfoot id='7L8jW'></tfoot>

                    • <bdo id='7L8jW'></bdo><ul id='7L8jW'></ul>

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