How to build opencv and boost both in visual studio 2013? /MTd? /MDd?

722 Views Asked by At

I use boost library and openCV with Visual Studio 2013 in windows 7.

When I build them, there are many errors like that.

opencv_core2410d.lib(alloc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in structure.obj

So, I search this error, and change Runtime Library of project's properties from /MDd to /MTd.

After that, These error is disappear. But, There are other errors like that.

libboost_system-vc120-mt-gd-1_57.lib(error_code.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in structure.obj

I built boost library like this before.

 b2 toolset=msvc-12.0 variant=debug,release link=static threading=multi address-model=32 runtime-link=static

I build runtime-link static(/MTd) right. I don't know why I cannot compile boost with /MTd option. How can i do?

1

There are 1 best solutions below

0
flec On

If you are using CMake you can add the following line to your CMakeLists.txt

set(OpenCV_STATIC OFF)

so it becomes

set(OpenCV_STATIC OFF)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

After that you need to add your OpenCV dlls to the Path. For example:

PATH_TO_OpenCV\build\x64\vc12\bin

After that it should work using /MDd.

I had the same problem when using OpenCV with Qt and this helped me getting started: https://github.com/nickdademo/qt-opencv-multithreaded