OpenGL Contents

Sid Kraft 46 Reputation points
2026-07-06T13:51:35.4+00:00

Interesting, downloaded the files for OpenGL, C++ use in Visual Studio. When I included the headers glut.h, got several compiler errors saying "C" not recognized. Opened the glut.h file and following shown???

Developer technologies | C++
Developer technologies | C++

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Nancy Vo (WICLOUD CORPORATION) 7,495 Reputation points Microsoft External Staff Moderator
    2026-07-07T03:24:13.3766667+00:00

    Hello @Sid Kraft ,

    Thanks for your question.

    Inside the glut.h file, there is a line of code that says extern "C". This is a special instruction meant only for C++ programs. However, if your main code file in Visual Studio was created with a .c extension instead of a .cpp extension, Visual Studio acts strictly as an older C compiler, gets confused by that command, and throws those errors.

    I recommend renaming your source file:

    • In your Solution Explorer on the right, find your main code file (it might be named Source.c or main.c).
    • Right-click it, select Rename, and change the extension to .cpp (like main.cpp).

    However, I highly recommend we take a step back.

    The reason you keep running into these compiler errors, missing .obj files, and Linker issues is because the glut-3.7 files you downloaded are completely obsolete. Modern Visual Studio struggles to read them properly.

    As we discussed in the previous thread, the recommended way to avoid all of this manual troubleshooting is to use the modern vcpkg tool that we set up.

    Please consider this approach since Visual Studio will automatically link the modern, correct files for you.

    Hope this helps. Thank you so much for your patience.

    Was this answer helpful?


  2. Darran Rowe 2,616 Reputation points
    2026-07-06T18:35:13.28+00:00

    Are you including Windows.h before? On Windows, glut.h includes gl.h and glu.h. These defines functions in a Windows API compatible way, and some of these definitions are only defined in Windows.h.

    #include <Windows.h>
    #include <GL/gl.h>
    #include <GL/glu.h>
    #include <GL/glut.h>
    
    extern"C"
    int wmain()
    {
    	return 0;
    }
    

    This builds without issue on my system.

    Screenshot 2026-07-06 193406

    Otherwise give the errors exactly as the compiler emits them. Don't try to interpret them. Also, it also helps if you give information as to the file and line that the error occurs on. This way, it lets other people actually inspect the code to determine what is going on.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.