Thread: New to OpenGL: Errors when compiling

  1. #1
    Registered User
    Join Date
    Apr 2021
    Posts
    1

    New to OpenGL: Errors when compiling

    Hey all,

    I'm trying to get into programming after about 15 years. I want to learn different API's, and decided to start with OpenGL. I assume I've set something up wrong, or I haven't installed something I require.

    I installed MinGW-w64, cmake, and make from their binaries. I used cmake and make to compile and install freeglut 3.2.1 and glew 2.1.0 under the x86_64-w64-mingw32 folder. I downloaded a c file from here.

    I try to compile using the following..

    Code:
    gcc -o opengl.exe abgr.c
    ..and I get the following in the command prompt

    Code:
    C:\Users\Kaega\Documents\Programming\FirstOpenGL>gcc -o opengl.exe abgr.c
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x25): undefined reference to `__imp___glutInitWithExit'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x4c): undefined reference to `__imp___glutCreateWindowWithExit'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x72): undefined reference to `__imp___glutCreateMenuWithExit'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x95): undefined reference to `__imp_glMatrixMode'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x9e): undefined reference to `__imp_glLoadIdentity'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0xd5): undefined reference to `gluPerspective'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0xe1): undefined reference to `__imp_glMatrixMode'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0xef): undefined reference to `__imp_glDisable'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x295): undefined reference to `__imp_glEnable'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x2b0): undefined reference to `__imp_glTexParameterf'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x2cb): undefined reference to `__imp_glTexParameterf'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x2e6): undefined reference to `__imp_glTexParameterf'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x301): undefined reference to `__imp_glTexEnvf'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x34c): undefined reference to `__imp_glTexImage2D'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x35a): undefined reference to `__imp_glBegin'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x373): undefined reference to `__imp_glTexCoord2f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x394): undefined reference to `__imp_glVertex3f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x3a9): undefined reference to `__imp_glTexCoord2f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x3ca): undefined reference to `__imp_glVertex3f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x3db): undefined reference to `__imp_glTexCoord2f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x3fc): undefined reference to `__imp_glVertex3f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x411): undefined reference to `__imp_glTexCoord2f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x432): undefined reference to `__imp_glVertex3f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x43b): undefined reference to `__imp_glEnd'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x449): undefined reference to `__imp_glDisable'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x475): undefined reference to `__imp_glClearColor'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x483): undefined reference to `__imp_glClear'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x4a4): undefined reference to `__imp_glRasterPos3f'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x4cf): undefined reference to `__imp_glDrawPixels'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x4ea): undefined reference to `__imp_glutSwapBuffers'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x4f5): undefined reference to `__imp_glFlush'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x607): undefined reference to `__imp_glutInitDisplayMode'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x623): undefined reference to `__imp_glutExtensionSupported'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x66a): undefined reference to `__imp_glutKeyboardFunc'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x67a): undefined reference to `__imp_glutDisplayFunc'
    D:\TEMP\USER\cclOlIIs.o:abgr.c:(.text+0x683): undefined reference to `__imp_glutMainLoop'
    collect2.exe: error: ld returned 1 exit status
    What am I doing wrong here exactly?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    You need to link to the library containing the references.

    -lLibraryName

    The "-l" is a dash with lowercase L.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with errors in compiling
    By m-kosier in forum C Programming
    Replies: 5
    Last Post: 11-29-2011, 06:31 PM
  2. Need Help in Compiling errors
    By sick in forum C Programming
    Replies: 2
    Last Post: 01-21-2010, 03:26 AM
  3. opengl Nehe tutorial errors when compiling
    By gell10 in forum Game Programming
    Replies: 4
    Last Post: 07-14-2003, 08:09 PM
  4. I get errors, but not from compiling
    By Leeman_s in forum C++ Programming
    Replies: 1
    Last Post: 01-20-2002, 02:07 PM
  5. Compiling OpenGl
    By Jamazon in forum C++ Programming
    Replies: 0
    Last Post: 11-19-2001, 01:51 AM

Tags for this Thread