I've recently installed OpenCV and everything so far has been working, but for some reason even if I include: cv.h, highgui.h I get this error when I want to use the function:
cvCalcOpticalFlowHS: error C2065: 'cvCalcOpticalFlowHS' : undeclared identifier.
I've tried to look up which header file needs to be included, but I've had no succes so far.
Do
#include "opencv2/legacy/legacy.hpp"
Related
I have recently attempted to switch my C++ project's target from an executable to a dynamic library (.dylib), and as soon as I rebuilt with the new target, I get a few errors saying that some defines and declarations in math.h are undeclared, such as M_PI and the sqrt() function.
The error message is as follows: error: use of undeclared identifier 'M_PI', and error: use of undeclared identifier 'sqrt'
This only occurs when I am building my project as a library, and I cannot figure out why it is doing this.
If anyone can help me out on this, it would be much appreciated!
Edit:
Also, if I try to change my include to #include <cmath>, I get more errors, such as: No member named 'signbit' in the global namespace.
Make sure #include <cmath> is at the top of the code, above int main(). I had the same problem. moving the #include <cmath> below <iostream> and above int main() solved the problem for me.
I am getting the following error while trying to build opencv with the contrib module
/opencv/opencv_contrib/modules/tracking/include/opencv2/tracking/tracker.hpp:577:11: error: ‘AlgorithmInfo’ does not name a type
The code is latest and pulled just now.
After adding a forward declaration class AlgorithmInfo; to the file tracker.hpp that particular error is gone but I am getting other '‘AlgorithmInfo’ does not name a type' errors in other files. Probably AlgorithmInfo is not getting included somehow. Any ideas?
Investigation:
After grepping AlgorithmInfo I found that there is no defination of AlgorithmInfo in the code base.
Comparing to the previous version of code I found AlgorithmInfo is defined at opencv2/core.hpp line 3006. But in the latest code, it is not present there at all!
This is not a permanent solution but I had the same issue and here is how i was able to continue work on the project until someone finds a better way.
I looked at the link that Utkarsh posted How do I use SIFT in OpenCV 3.0 with c++?
To summarize I had to get the opencv_contrib repo and remake opencv.
After doing so I still got the same error and eventually realized that
you must include
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/features2d/features2d.hpp"
but you still get the same unless you also remove/comment out
//#include "opencv2/nonfree/features2d.hpp"
//#include "opencv2/nonfree/nonfree.hpp"
anyway this is how i got around the error for the time being.
The short code is as follows:
#include <windows.h>
#include <GL/gl.h>
#include <GL/glext.h>
int main(int argc, char** argv)
{
PFNGLBINDPROGRAMARBPROC glBindProgramARB;
glBindProgramARB=(PFNGLBINDPROGRAMARB)wglGetProcAddress("glBindProgramARB");
}
When I compile, I got a compile error: error C2065: 'PFNGLBINDPROGRAMARB' : undeclared identifier.
I have checked the header file glext.h but PFNGLBINDPROGRAMARBPROC is in it (Line 2922). I have no idea so post my question here for help.
I'm using Visual Studio 2012 and I have checked the include directory settings. Other system info: Windows 7 64 bit, nVidia Geforce card with latest driver installed. If you need any other related info please ask.
It's a compile error, not a link error so it has nothing to do with the existence of the extension function glBindProgramARB (It does exist in my system, I checked using glutGetProcAddress).
I know FreeGlut and GLEW library functions can help me do the same thing. But I'm just wondering why the above code can not pass the compiler and how to fix it.
PFNGLBINDPROGRAMARBPROC is defined, but PFNGLBINDPROGRAMARB is not. You use the first of these two in the declaration, but the second in the type cast:
PFNGLBINDPROGRAMARBPROC glBindProgramARB;
glBindProgramARB=(PFNGLBINDPROGRAMARB)wglGetProcAddress("glBindProgramARB");
I am new to working in Visual Studio (am using version 2005). I am running into a problem with namespaces that I am not able to figure out.
I am trying to create a static library which I will link to an Application later.
So, I have a XXX.h file with the following code
#ifndef _XXX_X_H
#define _XXX_X_H
namespace LLL_NWK
{
void lllInit();
}
#endif
I include XXX.h in XXX.c and the code looks like
#include "XXX.h"
using namespace LLL_NWK;
void lllInit()
{
}
However, when I build the Library I encounter the following errors
error C2061: syntax error : identifier 'LLL_NWK'
error C2059: syntax error : ';'
error C2449: found '{' at file scope (missing function header?)
error C2059: syntax error : '}'
I am unable to figure out the cause of this error. Would appreciate some help and pointers.
First, using namespace LLL_NWK is not appropriate here. You are declaring and defining a function void lllInit() outside of namespace LLL_NWK. You need to place the definition inside of the namespace, which can be done like this:
void LLL_NWK::lllInit()
{
}
or like this:
namespace LLL_NWK
{
void lllInit()
{
}
}
Second, make sure you compile the code as C++.
That code is not supported by the C compiler - makes sure to rename the filename to .cpp instead .c. In this case, namespace is not supported. See this post: Namespaces in C
I have an extern code written in C in my C++ project in MS VS 2010. It comes with .h and .c files and I use include like this:
extern "C"{
#include "Extern\libname.h"
}
It worked nice. Then I read Google C++ style guide and removed all entries of
using namespace std;
replaced them with just
std::whatINeed
everywhere.
And the error showed up -
error C2065: 'FILE' : undeclared identifier
in the header of extern library. And then I move cursor to the word "FILE" in that code, there is
tydef _iobuf FILE
What should I add into my code to fix it? I don't want to change extern code because it can be updated and I will be forced to add my fixes on every update. Also, I am sure that there is a simple bug caused by me.
add
#include <cstdio>
above you include.