Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8700117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:06:47+00:00 2026-06-13T02:06:47+00:00

I want to compile a GLUT program #include <GL/glut.h> int main(int argc, char **argv)

  • 0

I want to compile a GLUT program

#include <GL/glut.h>

int main(int argc, char **argv) {

    // init GLUT and create Window
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(320,320);
    glutCreateWindow("Lighthouse3D- GLUT Tutorial");

    return 1;

}

Compile and link command:

gcc -o main.exe main.c -lglut32

Result:

main.o:main.c:(.text.startup+0x1c): undefined reference to `glutInit'
main.o:main.c:(.text.startup+0x28): undefined reference to `glutInitDisplayMode'
main.o:main.c:(.text.startup+0x3c): undefined reference to `glutInitWindowPosition'
main.o:main.c:(.text.startup+0x50): undefined reference to `glutInitWindowSize'
main.o:main.c:(.text.startup+0x5c): undefined reference to `glutCreateWindow'
collect2: ld returned 1 exit status        

The actual lib file of glut (3.7.6, called glut32.lib) is in the lib folder of mingw and the include file in include/GL.

What to do now?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:06:49+00:00Added an answer on June 13, 2026 at 2:06 am

    Try it with libglut.a and libglut32.a instead of glut32.lib. To compile glut programs with minGW.

    Do GLUT for Win32 is a Windows port of the original GLUT library. It’s no longer maintained or supported. The MinGW “w32api” package already comes with two GLUT import libraries, “libglut.a” and “libglut32.a”, but doesn’t come with a glut header file.

    If you’ve ever downloaded a GLUT header from the internet, and attempted to link an application against either of these import libraries, you likely would have seen it fail with various undefined references.

    Setting Up GLUT for Win32 With MinGW Look for Setting Up GLUT for Win32 With MinGW

    If you want to have your own “build” of libglut32.a and glu32.dll.

    • Download Source glut-3.7.6-src.zip (4.76 MB)
    • Download makefile
    • Make the following modifications:

    Add the following lines to include/GL/glut.h starting at line 12:

     #ifdef __MINGW32__
     #define APIENTRY __stdcall
     #define CALLBACK __stdcall
     #endif
    

    Comment out line 21 in lib/glut/win32_winproc.c so that it looks:

    //#include <crtdbg.h>
    

    makefile line 5 replace:

    -enable-auto-import with –enable-auto-import

    run make


    Have tried it with the example.c file from the guidance in the link Setting Up GLUT for Win32 With MinGW.

    With the prebuild libs and the self compiled libs. Works both.

    below is the result.

    enter image description here

    Example GLUT Application

    example.c from the link above Setting Up GLUT for Win32 With MinGW.

    #include <stdlib.h>
    #include <GL/glut.h>
    
    void keyboard(unsigned char key, int x, int y);
    void display(void);
    
    
    int main(int argc, char** argv)
    {
      glutInit(&argc, argv);
      glutCreateWindow("GLUT Test");
      glutKeyboardFunc(&keyboard);
      glutDisplayFunc(&display);
      glutMainLoop();
    
      return EXIT_SUCCESS;
    }
    
    
    void keyboard(unsigned char key, int x, int y)
    {
      switch (key)
      {
        case '\x1B':
          exit(EXIT_SUCCESS);
          break;
      }
    }
    
    
    void display()
    {
      glClear(GL_COLOR_BUFFER_BIT);
    
      glColor3f(1.0f, 0.0f, 0.0f);
    
      glBegin(GL_POLYGON);
        glVertex2f(-0.5f, -0.5f);
        glVertex2f( 0.5f, -0.5f);
        glVertex2f( 0.5f,  0.5f);
        glVertex2f(-0.5f,  0.5f);
      glEnd();
    
      glFlush();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to compile a 'c' code and create an executable from my application.
I want to compile my program with profiling, so I run: $ cabal configure
I want to compile a very basic hello world level Cuda program under Linux.
I'm trying to create an Glut window with Qt creator. All my code has
I want to compile a c++ program to a dll and use it from
I want to compile a program using the standard ./configure , make, make install.
I want to compile a Haskell program on one Linux box, and then run
I want to compile and execute a very simple program in 64 bit. section
I want to compile an OpenGL program but I don't have the necessary headers.
i want to compile a .cs program which exist in some other folder on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.