链接 libeay32MD.lib 和 libeay32MT.lib 之间有什么区别?
我有带有源代码的第三方应用程序,当前设置为针对 libeay32MD.lib 构建。但这是应用程序,而不是库。那么它不应该针对 libeay32MT.lib 构建吗?两者有什么区别?
库有以下变体:
- libeay32MD.lib
- libeay32MDd.lib
- libeay32MT.lib
- libeay32MTd.lib
和同名的“静态”库。您能解释一下它们之间的区别吗?
I have third-party application with source, which is currently set to be built against libeay32MD.lib. But this is application, not library. Shouldn't it be built against libeay32MT.lib then? What's the difference between two?
There are the following variants of libraries:
- libeay32MD.lib
- libeay32MDd.lib
- libeay32MT.lib
- libeay32MTd.lib
and "static" ones with the same name. Can you explain the difference between all of them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这些变化决定了使用哪个 C++ 库以及生成什么类型的代码,尽管只有“M”可用意味着多线程,但不再有单线程选项。
刚刚编辑 - 抱歉,代码顺序错误。
编辑 2:更多信息...
这些标志是 C++ 选项,与需要 ssleay32.dll 和 libeay32.dll 无关。 libeay32 有 8 个版本 - 4 个用于静态构建(不依赖于 ssl/libeay32.dll),4 个用于动态构建(需要 ssl/libeay32.dll)。这 4 种类型中的每一种都分为所需的 C++ 库 类型...
C++ 可用于静态或动态链接到您的应用程序,对于每种类型,您都可以使用调试库或发布库。
/MT 和 /MTd(静态)不需要 C++ 可再发行代码,因为所有 C/C++ 调用都包含在已编译的程序中。如果您链接到的每个模块(不仅是 ssleay & co.)都使用这些选项,则您的应用程序在 C++ 依赖项方面将完全独立。
/MD 和 /MDd(动态)需要在目标计算机上安装 C++ 可再发行 DLL。对于 /MD,可以轻松地从 MSFT 下载发行版,但您还需要注意您使用的 Visual C++ 版本 - 例如 VC++ 2008、VC++ 2010 等。您可能需要许多版本的可再发行版本。对于 /MDd,这些库将位于您的开发计算机上,但 MSFT 没有为此提供通用版本 - 但如果需要,您可以使用 Visual Studio 构建自己的安装程序;通常/MDd仅由开发人员用于测试。
原始问题中的 SSLEAY 等版本并未指示使用 Visual C++ 的哪个版本 2005/2008/2010 等来编译 MD 版本,但编译后,可以使用依赖项查看器从构建的目标中注意到(例如依赖。EXE文件)。例如,如果您的应用程序依赖于 MSVCR90.DLL,那么这意味着 VC++ 9(令人困惑的是,这是 2008 年的可再发行版本)。
所有开发人员都需要选择静态或 DLL 库链接,以下是每个链接的一些注意事项:
静态链接:
动态链接:
当库中的代码返回 C/C++ 对象(例如分配的内存、std::string 等)时,它是强制将您的代码与用于编译库的相同标志链接起来,无一例外。
These variations determine which C++ library is used, and what type of code is generated, although only 'M' is available meaning multi-threaded, there are no single-threaded options any more.
Just edited - sorry, codes were in wrong order.
Edit 2: More info...
These flags are C++ options and nothing to do with requiring ssleay32.dll and libeay32.dll. There are 8 version of libeay32 - 4 for a static build (no dependency on ssl/libeay32.dll) and 4 for dynamic build (requires ssl/libeay32.dll). Each of the 4 are divided into the type of C++ library required...
C++ is available to link statically or dynamically to your application, and for each of these types you can use debug libraries or release libraries.
/MT and /MTd (static) do not require the C++ redistributable code because all the C/C++ calls are contained inside your compiled program. If every module (not only ssleay & co.) you link to uses these options, your app will be fully stand-alone in terms of C++ dependencies.
/MD and /MDd (dynamic) need the C++ redistributable DLL's installed on the target computer. For /MD the releases are easily downloaded from MSFT, but you also need to note which version of Visual C++ you used - e.g. VC++ 2008, VC++ 2010 etc. there are many versions of the redistributable that you may need. For /MDd, the libraries will be on your development computer but there is no general release from MSFT for this - but you can build your own installer if necessary using Visual Studio; usually /MDd is only used by the developer for testing.
The versions of SSLEAY etc in the original question do not indicate what version 2005/2008/2010 etc of Visual C++ was used to compile the MD versions, but once compiled, it can be noted from the built target using a dependency viewer (e.g depends.exe). E.g. if your app depends on MSVCR90.DLL, then that means VC++ 9 (confusingly, that's the 2008 redistributable).
All developers need the option to choose static or DLL library linkage, here are some notes on each:
Static linkage:
Dynamic linkage:
When you have code in a library that returns a C/C++ object (e.g. allocated memory, std::string, etc) it is mandatory to link your code with the same flags used to compile the library, with no exceptions.
MD
用于动态发布MDd
用于动态调试MT
用于静态发布MTd
用于静态调试源文章来自 archive.org[^1]。
[^1]: 原始链接
MD
for dynamic-releaseMDd
for dynamic-debugMT
for static-releaseMTd
for static-debugSource article via archive.org[^1].
[^1]: Original Link
从名称猜测,一个库用于多线程,另一个库用于带有调试符号的多线程。
Guessing from the names, one library is for multithread and the other for multithread with debugging symbols.