000022055 - How to resolve library conflicts in RSA BSAFE Crypto-C or Cert-C (e.g. link errors such as LNK4098 and LNK2005)

Document created by RSA Customer Support Employee on Jun 16, 2016Last modified by RSA Customer Support Employee on Apr 21, 2017
Version 2Show Document
  • View in full screen mode

Article Content

Article Number000022055
Applies ToRSA BSAFE Crypto-C
RSA BSAFE Cert-C
Microsoft Windows
IssueHow to resolve library conflicts in RSA BSAFE Crypto-C or Cert-C (e.g. link errors such as LNK4098 and LNK2005)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _strncmp already defined in LIBCD.lib(strncmp.obj)
LINK : warning LNK4098: defaultlib "library" conflicts with use of other libs
CauseThese and similar errors are caused by linking the application with different standard C run-time libraries than those used by the RSA BSAFE libraries.
ResolutionThe Visual C++ compiler option /ML, /MT or /MD linked with the application needs to match the option used to build the RSA BSAFE libraries

The Visual C++ Compiler Options /ML, /MT and /MD determine the source and nature of the standard C run-time libraries linked with the application

/ML causes the compiler to link with LIBC.lib, which does not provide multithreaded support

/MT causes the compiler to link with LIBCMT.lib, which provides multithreaded support

/MD causes the compiler to link with MSVCRT.lib, which dynamically links with MSVCR71.DLL and provides multithreaded support

According to Microsoft: "Do not mix static and dynamic versions of the run-time libraries. Having more than one copy of the run-time libraries in a process can cause problems, because static data in one copy is not shared with the other copy. The linker prevents you from linking with both static and dynamic versions within one .exe file, but you can still end up with two (or more) copies of the run-time libraries. For example, a dynamic-link library linked with the static (non-DLL) versions of the run-time libraries can cause problems when used with an .exe file that was linked with the dynamic (DLL) version of the run-time libraries. NOTE: You should also avoid mixing the debug and non-debug versions of the libraries in one process.

Crypto-C releases prior to 6.2.0 are built with /ML. Since 6.2.0, there are 3 separate Crypto-C directories: intel_ia32, intel_ia32mt and intel_ia32md which respectively contain /ML, /MT and /MD builds.

Cert-C releases prior to 2.7.2.0 did not include an /MD build. Since 2.7.2.0, there are 6 separate Cert-C directories containing release and debug versions of /ML, /MT and /MD builds.

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_.2f.MD.2c_2f.ML.2c_2f.MT.2c_2f.LD.asp for more information regarding the proper uses of /ML, /MT and /MD.
Legacy Article IDa26563

Attachments

    Outcomes