Microsoft Developer Network > Forums Home > Visual Studio Express Editions Forums > Visual C++ Express Edition > Visual C++ 2005 Express Edition with OpenGL -- Can't get started
Ask a questionAsk a question
 

AnswerVisual C++ 2005 Express Edition with OpenGL -- Can't get started

  • Wednesday, April 19, 2006 11:46 AMMattFunke Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I'd like to get started using OpenGL with Visual C++ 2005 Express Edition.  I've installed VC++ and the PSDK.  I've tried to start a new Win32 application, and here's the exent of my code:

    // OpenGL Stuff 2.cpp : Defines the entry point for the console application.

    //

    #include "stdafx.h"

    #include <GL/gl.h>

    int _tmain(int argc, _TCHAR* argv[]) {return 0;}

    The error returned when I try to "Build -> Build OpenGL Stuff 2" is as follows:

    c:\documents and settings\mfunke\my documents\visual studio 2005\projects\opengl stuff 2\opengl stuff 2\opengl stuff 2.cpp(5) : fatal error C1083: Cannot open include file: 'GL/gl.h': No such file or directory

    Where can I get the right include files?  Any help you can lend would be greatly appreciated.

Answers

  • Friday, April 21, 2006 2:06 PMOShah Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    It needs to be placed after #include "stdafx.h", or within the file stdafx.h, otherwise it will be ignored.

All Replies

  • Wednesday, April 19, 2006 11:53 AMOShah Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
     MattFunke wrote:

    I'd like to get started using OpenGL with Visual C++ 2005 Express Edition.  I've installed VC++ and the PSDK.  I've tried to start a new Win32 application, and here's the exent of my code:

    // OpenGL Stuff 2.cpp : Defines the entry point for the console application.

    //

    #include "stdafx.h"

    #include <GL/gl.h>

    int _tmain(int argc, _TCHAR* argv[]) {return 0;}

    The error returned when I try to "Build -> Build OpenGL Stuff 2" is as follows:

    c:\documents and settings\mfunke\my documents\visual studio 2005\projects\opengl stuff 2\opengl stuff 2\opengl stuff 2.cpp(5) : fatal error C1083: Cannot open include file: 'GL/gl.h': No such file or directory

    Where can I get the right include files?  Any help you can lend would be greatly appreciated.

    Did you install the PSDK at "C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK"?

    see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=7004&SiteID=1 for a similar issue.

  • Wednesday, April 19, 2006 2:17 PMMattFunke Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    All right -- I made a PlatformSDK directory under Microsoft Visual Studio 8\VC and copied the Bin, Include, and Lib directories from

    c:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2

    to

    c:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK

    ... as suggested by the article you pointed me to.  The minimal program above now generates 143 errors; I'll include the first few for you, since they all seem to be caused by the same thing:

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C2144: syntax error : 'void' should be preceded by ';'

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C2146: syntax error : missing ';' before identifier 'glAccum'

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C2182: 'APIENTRY' : illegal use of type 'void'

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    Here's line 1152 of the indicated file:

    WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value);

    My guess is that it doesn't recognize the identifiers WINGDIAPI or APIENTRY.  Is there another include file that I'm missing?

  • Thursday, April 20, 2006 10:38 PMOShah Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    #include <windows.h>
  • Friday, April 21, 2006 12:30 PMMattFunke Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Done, as the first line in the program.  The same errors remain as in my previous posting under this header (the same error numbers, the same locations in gl.h).
  • Friday, April 21, 2006 2:06 PMOShah Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    It needs to be placed after #include "stdafx.h", or within the file stdafx.h, otherwise it will be ignored.
  • Friday, April 21, 2006 4:57 PMMattFunke Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Brilliant!  Thank you so very much for all your help!  I can hardly wait to get started on trying to learn OpenGL!

    (I only wish I could return the favor.)

  • Thursday, May 11, 2006 11:26 AMjapreja Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     MattFunke wrote:

    All right -- I made a PlatformSDK directory under Microsoft Visual Studio 8\VC and copied the Bin, Include, and Lib directories from

    An easier method instead of copying is to create a link to all your includes using the junction program from sysinternals.com

    http://www.sysinternals.com/Utilities/Junction.html

    It works in the same way "symbolic links" work on *NIX systems. it includes source code as well as an executable on the above web page.  I think the program can link networked files and directories as well.

    Using this will save space on your drive since your not copying dirs/files, your just making a junction/link.

  • Wednesday, September 05, 2007 7:35 PMbenktesh Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I am having similar problem. the error I get is

    1>c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs

    1> c:\program files\microsoft visual studio 8\vc\include\gl\glut.h(140) : see declaration of 'exit'

    1>c:\documents and settings\vruser\desktop\hww\hww\hww\hww.cpp(62) : error C2264: 'exit' : error in function definition or declaration; function not called

    1>Build log was saved at "file://c:\Documents and Settings\VRUSER\Desktop\hww\hww\hww\Debug\BuildLog.htm"

    1>hww - 2 error(s), 0 warning(s)

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  • Monday, November 19, 2007 11:01 AMiAlbeniz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have tried to include #include <windows.h>  and gives me an error:

    Error    1    fatal error C1083: No such file or directory

    any idea??


  • Monday, February 08, 2010 4:38 PMEn Xie Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     


    try use #include "windows.h".