0
votes

I am using two different third party libraries in my VC++ project . When I compile them then its giving me linking errors.

I have checked the sample applications with each of the library. Settings of sample application with first library (Lib1)

  • 1)Use MFC in Static Library
  • 2)Multi-Threaded Debug

Settings of sample application with first library (Lib2)

  • 1)Use MFC in a shared dll
  • 2)Multi-Threaded Dll

I am including first library in project by adding

#pragma comment(lib, "./lib/abc.lib") 

statement

Second library is added to project settings by adding it as Additional Dependencies.

Now it works fine but when I try to use some functions from Lib1 the I get errors like

1>libcmtd.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in msvcrtd.lib(MSVCR80D.dll) 1>libcmtd.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in msvcrtd.lib(MSVCR80D.dll) 1>libcmtd.lib(dbgheap.obj) : error LNK2005: _malloc already defined in msvcrtd.lib(MSVCR80D.dll) 1>libcmtd.lib(dbgheap.obj) : error LNK2005: _calloc already defined in msvcrtd.lib(MSVCR80D.dll)

Any solution how can I make my project compile with both the libraries. I dont have source code for those libraries so I can't compile them.

1

1 Answers

0
votes

The proper solution is to not use the debug build of library 1. Can you get/use the release build? That way you are not linking against debug AND release version of system dll's.

If you cannot obtain the release build, then you will have to exclude the debug .libs from being used.

This link explains how to do it.

The libs that end with d are the debug versions (libcmtd.lib). Those are the one you wish to exclude (for your release build). For you debug build you will want to exlcude the release libs.