When developing C/C++ applications on Windows, there are multiple versions of the C run-time library to choose from:
- Single-Threaded (statically linked)
- Multi-Threaded (statically linked)
- Multi-Threaded DLL
- Debug Single-Threaded (statically linked)
- Debug Multi-Threaded (statically linked)
- Debug Multi-Threaded DLL
Most of the time you don’t need to concern yourself with this setting. However, different versions of the C run-time library may not play well together.
For example, I recently discovered that if you try to link a piece of code which uses a static version of the C run-time library to a static library which uses a DLL version of the C run-time library, you will get errors of the form:
Linking... MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _printf already defined in LIBCD.lib(printf.obj) LINK : warning LNK4098: defaultlib "MSVCRTD" conflicts with use of other libs; use /NODEFAULTLIB:library Debug/Exe.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe.
Therefore, if you run across errors like this, check that all your projects use the same C run-time library. In Microsoft Visual C++ 6.0, the choice of C run-time library is provided under Project Settings > C/C++ > Code Generation > Use run-time library. Here is a picture of the dialog:
Recent Comments