简体   繁体   English

如何在Visual Studio 2013中构建opencv并增强两者? / MTD? / MDD?

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

I use boost library and openCV with Visual Studio 2013 in windows 7. 我在Windows 7中将Boost库和openCV与Visual Studio 2013一起使用。

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 . 因此,我搜索了此错误,并将项目属性的运行库从/ MDd更改/ 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. 之前我像这样构建了boost库。

 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. 我正确地建立了runtime-link static( / MTd )。 I don't know why I cannot compile boost with /MTd option. 我不知道为什么我不能使用/ MTd选项编译boost。 How can i do? 我能怎么做?

If you are using CMake you can add the following line to your CMakeLists.txt 如果您使用的是CMake,可以将以下行添加到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. 之后,您需要将OpenCV dll添加到路径中。 For example: 例如:

PATH_TO_OpenCV\build\x64\vc12\bin

After that it should work using /MDd. 之后它应该使用/ MDd。

I had the same problem when using OpenCV with Qt and this helped me getting started: https://github.com/nickdademo/qt-opencv-multithreaded 使用OpenCV和Qt时遇到了同样的问题,这有助于我入门: https//github.com/nickdademo/qt-opencv-multithreaded

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM