AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.57k stars 7.95k forks source link

vs2015 build yolo_cpp_dll debug version failed on opencv3.3.0 #233

Open blakeliu opened 6 years ago

blakeliu commented 6 years ago

1>d:\dependency\opencv3.3.0\include\opencv2\core\cvdef.h(58): error C2061: 语法错误: 标识符“cv” 1>d:\dependency\opencv3.3.0\include\opencv2\core\cvdef.h(434): fatal error C1070: 文件“d:\dependency\opencv3.3.0\include\opencv2\core\cvdef.h”中的 #if/#endif 对不匹配

but, vs2015 build yolo_cpp_dll release version success!.

yuanxy92 commented 6 years ago

I encounter the same problem if compiling static lib:

image

AlexeyAB commented 6 years ago

@blakeliu @yuanxy92 Hi, I can't reproduce your errors. I can compile Release or Debug & x64. And Dynamic or Static library. MSVS 2015, OpenCV 3.2.0 on Windows 7 x64. Also yolo_cpp_dll.sln by default compiled without OpenCV, so I don't know why there are occurs errors depends on OpenCV.

Try to do:

open \yolo_cpp_dll.sln -> (right click on project) -> properties -> C/C++ -> Preprocessor -> Undefine Preprocessor Definitions, and add here OPENCV

blakeliu commented 6 years ago

@AlexeyAB opencv3.3.0, not opencv3.2.0

AlexeyAB commented 6 years ago

@blakeliu Right now I downloaded OpenCV 3.3.0: https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.3.0/opencv-3.3.0-vc14.exe/download And I successfully compiled yolo_cpp_dll.sln: Release or Debug & x64. Dynamic or Static library. MSVS 2015, OpenCV 3.3.0 on Windows 7 x64.

YingUK commented 6 years ago

Hi @blakeliu I faced the same issue before . I created system variable for OPENCV_BUILD directory So in the MSVS config steps, like below,
(right click on project) -> properties -> C/C++ -> General -> Additional Include Directories
i used PATHs like: $(OPENCV_BUILD)\opencv\build\include etc. this was causing the issue.

When I changed to the full path, e.g. C:\opencv_2.4.13\opencv\build\include, I don't see this issue anymore.

blakeliu commented 6 years ago

win10, opencv3.3.0, vs2015 build yolo_cpp_dl debug version still failed default

KD-93 commented 6 years ago

Check the configuration properties as well as the version of opencv, which the author defines using version 3.0.0 instead of 3.3.0.

SpaceView commented 5 years ago

Dears, it seems this problem only happens in debug mode, for release mode it is of no problem. I got the same error, still not solved it with opencv3.3.0 (with IDE visual studio 2015) yet. I found that delete the OPENCV definition from the project properties --> c/c++ --> preprocess --> preporcess definitions (remove the "OPENCV" here), the project will be OK (in debug mode). thus it seems the problem is from opencv versions, need further checking to understand...

while I changed to Opencv3.2.0, Opencv3.0.0, both compiled successfully, for the debug mode. the link for opencv3.2.0 is https://nchc.dl.sourceforge.net/project/opencvlibrary/opencv-win/3.2.0/opencv-3.2.0-vc14.exe

Another issue (not related to the above one) is that you need to

if defined(WIN32)

include

endif

in the Darknet.c, since in debug mode the author uses _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); to trace the memory leak! Otherwise it will report an error C2065: “_CRTDBG_ALLOC_MEM_DF”: not defined.