Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unable to compile/link program after inclusion of opencv.hpp

I am trying to compile a program which uses opencv. I have included the opencv.hpp file in the .h and the .c file which needs the opencv functions. The project also has the properties set to use opencv. I am using 2.4.5 version of opencv. The problems I am facing is that after including these files in the project the project fails to compile. I get an error saying I have failed to #inlcude "stdafx.h". This is because I am using precompiled headers and #include"stdafx.h" has to be the first line of code in that .c or .cpp file. If I add the inclusion of stdafx.h tehn the program compiles but it does not link.

shown below is how i have included the files in the .c file.

include "../stdafx.h"

include "C:\opencv\include\opencv2\opencv.hpp"

include "DPD_AlgorithmInit.h"

and shown below is the inclusion in the .h file

include "C:\opencv\build\include\opencv2\core\types_c.h"

the error I am receiving is error C1083: Cannot open source file: '..\MOSS\PedestrianDetection\DPD_Tracker.c': No such file or directory C:\Users\sankalp\Desktop\check\MOSS_Evaluation\c1 error LNK2001: unresolved external symbol _InitializeTracker C:\Users\sankalp\Desktop\check\MOSS\DPD_AlgorithmInit.obj error LNK2001: unresolved external symbol _DPD_Tracker C:\Users\sankalp\Desktop\check\MOSS\DPD_AlgorithmInit.obj error LNK2001: unresolved external symbol "unsigned char * __cdecl DPD_Alloc(unsigned int)" (?DPD_Alloc@@YAPAEI@Z) C:\Users\sankalp\Desktop\check\MOSS\DPD_Tracker1.obj error LNK1120: 3 unresolved externals C:\Users\sankalp\Desktop\check\Release\MOSS.exe

Am I doing something wrong while including the .hpp file? Is there a better way to include opencv to alllow compilation and linking?

click to hide/show revision 2
No.2 Revision

updated 2015-10-08 05:38:29 -0600

berak gravatar image

Unable to compile/link program after inclusion of opencv.hpp

I am trying to compile a program which uses opencv. I have included the opencv.hpp file in the .h and the .c file which needs the opencv functions. The project also has the properties set to use opencv. I am using 2.4.5 version of opencv. The problems I am facing is that after including these files in the project the project fails to compile. I get an error saying I have failed to #inlcude "stdafx.h". This is because I am using precompiled headers and #include"stdafx.h" has to be the first line of code in that .c or .cpp file. If I add the inclusion of stdafx.h tehn the program compiles but it does not link.

shown below is how i have included the files in the .c file.

include "../stdafx.h"

include "C:\opencv\include\opencv2\opencv.hpp"

include "DPD_AlgorithmInit.h"

#include "../stdafx.h"
#include "C:\opencv\include\opencv2\opencv.hpp"
#include "DPD_AlgorithmInit.h"

and shown below is the inclusion in the .h file

include "C:\opencv\build\include\opencv2\core\types_c.h"

file #include "C:\opencv\build\include\opencv2\core\types_c.h"

the error I am receiving is

error C1083: Cannot open source file: '..\MOSS\PedestrianDetection\DPD_Tracker.c': No such file or directory    C:\Users\sankalp\Desktop\check\MOSS_Evaluation\c1
error LNK2001: unresolved external symbol _InitializeTracker    C:\Users\sankalp\Desktop\check\MOSS\DPD_AlgorithmInit.obj
error LNK2001: unresolved external symbol _DPD_Tracker  C:\Users\sankalp\Desktop\check\MOSS\DPD_AlgorithmInit.obj
error LNK2001: unresolved external symbol "unsigned char * __cdecl DPD_Alloc(unsigned int)" (?DPD_Alloc@@YAPAEI@Z)  C:\Users\sankalp\Desktop\check\MOSS\DPD_Tracker1.obj
error LNK1120: 3 unresolved externals   C:\Users\sankalp\Desktop\check\Release\MOSS.exe

C:\Users\sankalp\Desktop\check\Release\MOSS.exe

Am I doing something wrong while including the .hpp file? Is there a better way to include opencv to alllow compilation and linking?