开发者

What's the difference between linking against libeay32MD.lib and libeay32MT.lib?

开发者 https://www.devze.com 2023-02-02 11:35 出处:网络
I have third-party application with source, which is currently set to be built against libeay32MD.lib. But this is application, not library. 开发者_C百科Shouldn\'t it be built against libeay32MT.lib t

I have third-party application with source, which is currently set to be built against libeay32MD.lib. But this is application, not library. 开发者_C百科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?


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.

  • MTd = Multi threaded debug code, and linking to C++ static debug library
  • MDd = Multi threaded debug code, and linking to C++ dynamic (DLL) debug library
  • MT = Multi threaded, linking to C++ static library
  • MD = Multi threaded, linking to C++ dynamic (DLL) library

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:

  • self contained, easy to install, larger code footprint, duplication of code when building multiple dll's and exe's.

Dynamic linkage:

  • smaller footprint, bug fixes from MSFT updates, shared code, a bit harder to install

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 for dynamic-release
  • MDd for dynamic-debug
  • MT for static-release
  • MTd for static-debug

Source 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号