Compile error in a short OpenGL code: 'PFNGLBINDPROGRAMARB' : undeclared identifier - opengl

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");

Related

C++ Xcode Library - Undeclared math.h features

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.

native WebRTC with Visual Studio build error

I've succcessfully build native WebRTC and got webrtc.lib file in result. Then i was trying to setup Visual Studio 2017 simple project to use webrtc and I pointed include and library directory and also in dependencies added webrtc.lib. For some reason just simple code like this:
#define WEBRTC_WIN
#include<iostream>
#include<api/mediastreaminterface.h>
int main(int argc, char** argv)
{
return 0;
}
generates around 100 errors mainly about min and max functions and rtc::rtc namespace which is weird looks like somehow all rtc::x calls it interprets as rtc::rtc:x for example
Error C2039 'scoped_refptr': is not a member of 'rtc::rtc' webrtctest c:\libwebrtc\webrtc\src\api\mediastreaminterface.h 287
I've tried to download already compiled versions with different include files but got same errors. Also there is an error saying
Error C2059 syntax error: 'namespace' webrtctest c:\libwebrtc\webrtc\src\rtc_base\messagequeue.h 33
which is pointing to this line:
namespace rtc {
I've downloaded latest branch-69, and my windows sdk version is 10.0.17134.0
I've managed to make it work. I had to add #define NOMINMAX on top of everything because there were macros inside of windows.h with same name.

Why mandatory to include stdafx.h at the start?

I have this extremely simple main function
#include "stdafx.h"
#include "abc.h"
int _tmain(int argc, _TCHAR* argv[])
{
abc obj;
obj.show();
return 0;
}
Everything is compiling normally...but when i am writing
#include "abc.h"
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
abc obj;
obj.show();
return 0;
}
The compiler is going haywire..
error C2065: 'abc' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'obj'
error C2065: 'obj' : undeclared identifier
error C2228: left of '.show' must have class/struct/union
type is ''unknown-type''
Why is it mandatory to include
stdafx.h
at the start?
I am new in C++ ...maybe I am making a silly mistake. Please help :(
(Using: VS2005 with C++ 98)
The issue that you're seeing is the fact that MS Visual C++ uses a feature called precompiled headers by default (other compilers on other platforms have a similar feature, I recall GCC for example having this feature). This ensures that all the code referenced up to the point of the precompiled header is pre-compiled, thus the compiler has less work to do at compilation time.
What happened when you switched that around was that it assumed that the contents of "abc.h" were already pre-compiled when they actually weren't. One easy solution would be to put #include "abc.h" inside stdafx.h. See here for a more details explanation of how the stdafx.h header works.
The precompiled headers option can be easily turned off in the compiler options. There should be a "precompiled headers/precompilation" category in the options, was in earlier Visual C++ IDE's I've encountered.

opencv errors while using with windows form applications

I am using opencv with visual studio 2010 windows form application c++. but it wont allow calling inbuilt functions. It gives errors like
Error 1 error C3861: 'cvCvtColor': identifier not found c:\users\ayesha\documents\visual studio 2010\projects\abc\abc\Form1.h 140 1 abc
Error 2 error C3861: 'cvCvtPixToPlane': identifier not found c:\users\ayesha\documents\visual studio 2010\projects\abc\abc\Form1.h 146 1 abc
I have added the following headers
#include "highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
Can anyone please tell me what i am doing wrong.
Unfortunately, OP doesn't say what version of OpenCV he uses.
While working with OpenCV 3.0, use cvSplit() instead of cvCvtPixToPlane().
cvCvtColor() shall work with OpenCV 3.0, provided you added the required header files to your projects.
Finally, to make sure you don't miss any required files in your project, just start your code with #include <opencv2\opencv.hpp>.
cvCvtColor is a C API function of OpenCV, but you're intending to use the C++ one. You have 2 ways of fixing the problem:
1) (Recommended) Change your source code to use the C++ API. You should use cv::Mat instead of CvArr, cv::cvtColor instead of cvCvtColor, etc.
2) Since such changes in the source code can be pretty involved, you can still use the C API by including C-headers
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/core_c.h"
#include "opencv2/highgui/highgui_c.h"
instead of the C++ (*.hpp) ones
The error you've mentioned it is a linker error I suppose.
As you're including two headers highgui.hpp and highgui.h targeting to an identical library which is opencv_highgui23#.
Just include only one header.

C++ Non-Class member compile error in Code::Blocks?

I am attempting to follow the tutorial found here to learn the basic idea behind programming roguelike game. I am using Code::Blocks 10.05 running portable from my usb and compiling with MinGW. Console.h also came from the website I linked above.
I have hit a road block when I have attempted to set up just this class to ensure everything is working:
#include <conio.h>
#include "Console.h"
int main( void )
{
console.Clear();
return 0;
}
When I attempt to use the I get the following error:
Error: request for member 'Clear' in 'console', which is of non-class type 'Win32Console()'|
Any help is appreciated, thanks!
Edit
I reinstalled MinGW and Code::Blocks after promptly ruining them for myself and am now back with the error:
undefined reference to `Win32Console::Win32Console()
before adding the header file, paste this line: #define _WIN32. Its possible that the _WIN32 isn't defined?