Cannot compile 3D point viewer in Visual Studio 2008
Can someone help me ?I am trying to run the 3d point cloud viewer .However it shows me the following errors
Error 1 error C2144: syntax error : 'void' should be preceded by ';' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 3 error C2146: syntax error : missing ';' before identifier 'glAccum' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 4 error C2182: 'APIENTRY' : illegal use of type 'void' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\pro开发者_如何学Gogram files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1152 Viewer
Error 6 error C2144: syntax error : 'void' should be preceded by ';' c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1153 Viewer
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h 1153 Viewer
and so on ... Beginning of my code is :
#include <cstdlib>
#include <GL/glut.h>
#include <cmath>
#include "arcball.h"
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;
Can someone please tell me what is going wrong?
Well, the first reported error is on the first line that declares a function with the WINGDIAPI
modifier. Apparently, this is declared in wingdi.h
. However, I'm not sure if you're meant to #include
that directly, or whether there's a more formal recommendation for compiling opengl code in the windows environment. I'll have a hunt around.
The page on MSDN discussing the necessary headers for OpenGL work are a bit vague, but I take:
The Windows functions that support Microsoft's implementation of OpenGL in Windows must include the header file Windows.h.
To mean that you ought to include windows.h
first.
Really? If I create a blank C++ project in VS2008, create an empty cpp file, copy and paste your includes in, and hit compile, I get exactly the errors you described. If I change my includes to:
#include <cstdlib>
#include <windows.h>
#include <GL/gl.h>
#include <cmath>
#include "arcball.h"
#include <vector>
#include <iostream>
#include <fstream>
Then the first reported error I get is that it can't find "arcball.h" (hardly unexpected). Are you still getting the same errors once windows.h is included?
精彩评论