Menu

Another Linker Error

2007-08-10
2012-09-26
  • Spyder_Snyper

    Spyder_Snyper - 2007-08-10

    So I'm trying to learn OpenGL. I THINK I have everything properly set up. I have the appropriate header files in the \includes\GL folder. I have the #include <gl\gl.h> statements. But when I try to compile, I'm getting some linker errors. Here is the error log...

    Compiler: Default compiler
    Building Makefile: "E:\Programming\C++\OpenGL\Makefile.win"
    Executing make...
    make.exe -f "E:\Programming\C++\OpenGL\Makefile.win" all
    g++.exe main.o -o "OpenGL.exe" -L"lib" -mwindows

    main.o(.text+0x31):main.cpp: undefined reference to glViewport@16' main.o(.text+0x40):main.cpp: undefined reference toglMatrixMode@4'
    main.o(.text+0x48):main.cpp: undefined reference to glLoadIdentity@0' main.o(.text+0x76):main.cpp: undefined reference togluPerspective@32'
    main.o(.text+0x85):main.cpp: undefined reference to glMatrixMode@4' main.o(.text+0x8d):main.cpp: undefined reference toglLoadIdentity@0'
    main.o(.text+0xa2):main.cpp: undefined reference to glShadeModel@4' main.o(.text+0xcd):main.cpp: undefined reference toglClearColor@16'
    main.o(.text+0xda):main.cpp: undefined reference to glClearDepth@8' main.o(.text+0xe9):main.cpp: undefined reference toglEnable@4'
    main.o(.text+0xf8):main.cpp: undefined reference to glDepthFunc@4' main.o(.text+0x10f):main.cpp: undefined reference toglHint@8'
    main.o(.text+0x12c):main.cpp: undefined reference to glClear@4' main.o(.text+0x134):main.cpp: undefined reference toglLoadIdentity@0'
    collect2: ld returned 1 exit status
    make.exe: *** [OpenGL.exe] Error 1

    Execution terminated

    And on the topic of these errors, I'm trying to make sense of them, but I can't get what the errors are pointing to. For example, let's use the first error: "undefined reference to `glViewport@16'"

    I can find the code that has glViewport. No issues there. But the "@16"... What's the @16 supposed to mean??? It's not LINE 16, nor is it column (or character) 16. So what is it???

    Thanks...

     
    • Wayne Keen

      Wayne Keen - 2007-08-10

      Including the header is only part of the puzzle. The header is, in most case, just a menu, it doesn't
      have any code that does things. To do things, you need to link the associated libaries. They have the code, and do the real work.

      I recommend you read two sections in the "Please Read" thread

      (1) The section on the compile log, including headers, and linking libraries

      (2) The section on getting started with GLUT, the windows version of OpenGL.

      This should help clarify what is going on, and the mechanics of the process.

      Wayne

       
    • Wayne Keen

      Wayne Keen - 2007-08-10

      Note also that you do not need -L"lib" - the compiler knows where it's own libraries are.

      Note also that the command -mwindows tells the compiler that you are compiling a
      "Windows" application - now, that does not mean an application that runs on Windows,
      it means one that has GUI stuff in it.

      Wayne

       
    • Spyder_Snyper

      Spyder_Snyper - 2007-08-10

      thanks for making me look like an idiot...lol...

      thanks man. This info got the problem solved.

       
      • Wayne Keen

        Wayne Keen - 2007-08-11

        Well then I am a bigger idiot - it took me years to really understand what the role of a header and a library was.

        You learned it in hours.

        Wayne

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.