Tuesday 6 July 2010

error LNK2005: __vsnprintf already defined in LIBCMT.lib

MSVCRT.lib(MSVCR80.dll) : error LNK2005: __vsnprintf already defined in LIBCMT.lib(vsnprint.obj)

How many times have I seen this type of error? ....and how many times have I had to look up the answer? Too many.

So, while it's fresh in my mind, here's the solution.

Decide if you want your application to use runtime DLLs or to include them internally.

If you include internally then:
- You won't have the benefit of future runtime DLL patches
- You don't have to worry about DLLs following the exe around
- You will have the added cost of greater filesize

So choose either
/MT - (no DLLs) LIBCMT.lib is included
or
/MD - MSVCRT.lib is included and DLLs are used at runtime

The option is found in Project properties / Config properties / C/C++ / Code Generation / Runtime Library

If you experience the above error then you are mixing the two, which is bad. Check each lib that you are linking in conforms to your choice. Rebuild any that do not and the error will disappear like magic!



No comments:

Post a Comment