Building OpenCV 3.2.0 with VS2015 as x86 [closed]
I have code written many years ago (displayvideoqt) for Win32 that I want to add opencv functions to. I did all the include, linker, and library options in VS2015, compiled from scratch using CMake, etc and no matter what I try to tweak I always get the following error just from trying to use cv::Mat (#include <opencv2\core\core.hpp>
displayvideoqt.obj : error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd@cv@@YAHPAHH@Z) referenced in function "public: void __thiscall cv::Mat::release(void)" (?release@Mat@cv@@QAEXXZ)
I have found that in cv::Mat::release() CVX_ADD is defined as this cv::_interlockedExchangeAdd(int *, int) in core/system.hpp. It appears that the function is actually defined in core/operations.hpp but that the definition is not being linked to despite the fact that I have the opencv_core320d.lib in my linker.
I am using CMake, VS2015, and on Windows 10.
Any help would be much appreciated!
I don't understand "Building OpenCV 2.4.8" and "I have the opencv_core320d.lib".
displayvideoqt.obj do you build opencv with qt ?
The code I was given (displayvideoqt) uses qt but it's not essential for what I want to do with opencv.
I am compiling the code for OpenCV 2.4.8 from the source. As part of this of course I build opencv_core320d.lib which I then put into my property>linker sheet
You build opencv 3.2.0 and you cannot link your program.
check if you solution is in debug mode.
Can you move all your source code in another folder and build a basic program like this one using same solution
You're right - Im building OpenCV 3.2.0 - not 2.4.8 but that just was me being confused - I will revise the question - even the simplest code (below) fails
With this basic code make a new folder copy source file in this folder add ths CMakeLists.txt :
then run cmake select where is the source code the new folder where to build binaries the new folder press configure selec vs 14 2015
if cmake cannot find opencv give path where you build opencv and press generate
Not sure I totally understood this - I put it in and then I needed to find a FindOpenCV.cmake and then I had trouble figuring out all the paths like OpenCV_DIR_ROOT and OpenCV_CORE_DIR and OpenCV_HIGHGUI_LIBRARY, etc. Any ideas where these should all point?
I'm agree with you I don't understand what you are doing. I think You should forget VS and use only cmake. CMake will do everything for you include path path to lib platform x86 x64.... You don't need to set environment variables too. I made a little video to explain process.
Your method worked for the test script but not for my actual project - I still get the same error. I'll keep working on it.
try to disable videoio module in opencv and check if compiler option /Oi is used in your project
I got it eventually - your code helped once I figured it out. Thanks!!