OpenGL in Windows, small problem

Sharky Forums


Results 1 to 7 of 7

Thread: OpenGL in Windows, small problem

  1. #1
    Tiger Shark
    Join Date
    Oct 2000
    Location
    Erie, PA, USA
    Posts
    693

    OpenGL in Windows, small problem

    I'm pretty new at C++ for starters, and VERY new at Windows programming, but I got a book from the library about programming OpenGL apps in Windows. The book starts off with a very simple example: a Windows application that opens a window with an OpenGL rendering context, that has a simple red triangle rotating in the middle of the window. The code seems fairly straightforward, and I think I understand most of it.

    Here's the catch though. I type in the code EXACTLY as I see it in this book into my trusty VC++ 6.0 editor in a new empty project. It is a single .cpp file. I then compile the code. It compiles fine, zero errors, zero warnings. But when I go to run the executable, it asks me if I want to build it (i choose yes of course), then it gives me the following error messages...

    --------------------Configuration: MyFirstOpenGLApp - Win32 Debug--------------------
    Linking...
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol _gluPerspective@32
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__wglDeleteContext@4
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__wglCreateContext@4
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glRotatef@16
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
    BasicWindowsOpenGLApp.obj : error LNK2001: unresolved external symbol __imp__glClear@4
    Debug/MyFirstOpenGLApp.exe : fatal error LNK1120: 14 unresolved externals

    I really have no idea what these mean, and the book isn't any help on debugging issues. I realize it would help if I posted the entire program, but it's pretty lengthy. I'm just wondering if anybody here can tell me in general terms what these errors are?
    AMD AthlonXP 2600+ Thoroughbred B @ 200x10.5
    Shuttle AN35N nForce2 Ultra 400
    2x512MB Kingston PC3200 (3-3-3)
    ATI Radeon 9600 Pro
    40GB WD ATA-100 8MB cache
    Creative 12X DVD Drive
    Memorex 52X CD-RW
    Running Windows XP Pro

  2. #2
    Hammerhead Shark
    Join Date
    Sep 2000
    Location
    Edinburgh,UK
    Posts
    1,188
    You probably haven't installed the OpenGL libraries for Visual Studio. The problem isn't with the code (if it compiles it is probably fine) but the linking: a required library is missing. IIRC, libraries should be specified under Project -> Project Settings -> Link.
    Stoo

  3. #3
    Tiger Shark
    Join Date
    Mar 2001
    Posts
    615
    Yeah, you probably need to add opengl32.lib and possibly glut.lib or glut32.lib. opengl32.lib should be in your VC++ folder under lib/gl. You will have to download glut32 if you need it. I think there is another .lib you may need, but I can't remember. There is probably only 2-3 .lib files in the /gl directory, so add the other one if it is there.
    System specs:


    | Core i5 750 | GA-P55A-UD3 | 4.0 GB G.skill DDR3 1600 | eVGA 470 GTX |
    | Intel X25-M 80 GB SSD | WD 5000AAKS | Lian Li PC-7FN | Corsair TX750W |
    | Windows 7 Home 64-bit |

  4. #4
    Tiger Shark
    Join Date
    Mar 2001
    Posts
    615
    glu32.lib was the other library I was thinking of. Add it, as well.
    System specs:


    | Core i5 750 | GA-P55A-UD3 | 4.0 GB G.skill DDR3 1600 | eVGA 470 GTX |
    | Intel X25-M 80 GB SSD | WD 5000AAKS | Lian Li PC-7FN | Corsair TX750W |
    | Windows 7 Home 64-bit |

  5. #5
    Tiger Shark
    Join Date
    Oct 2000
    Location
    Erie, PA, USA
    Posts
    693
    Wow, thanks a lot! That did it. I had to add opengl32.lib and glu32.lib in the settings. Thanks again.
    AMD AthlonXP 2600+ Thoroughbred B @ 200x10.5
    Shuttle AN35N nForce2 Ultra 400
    2x512MB Kingston PC3200 (3-3-3)
    ATI Radeon 9600 Pro
    40GB WD ATA-100 8MB cache
    Creative 12X DVD Drive
    Memorex 52X CD-RW
    Running Windows XP Pro

  6. #6
    Tiger Shark
    Join Date
    Mar 2001
    Posts
    615
    No problem. BTW, anytime you see a link-time error, it is usually that you forgot to add or are missing a library. If you usually just compile and link together, all the '@' symbols, underscores, and words like "external symbol" are dead giveaways for a linker error.
    System specs:


    | Core i5 750 | GA-P55A-UD3 | 4.0 GB G.skill DDR3 1600 | eVGA 470 GTX |
    | Intel X25-M 80 GB SSD | WD 5000AAKS | Lian Li PC-7FN | Corsair TX750W |
    | Windows 7 Home 64-bit |

  7. #7
    Tiger Shark
    Join Date
    Oct 2000
    Location
    Erie, PA, USA
    Posts
    693
    Good to know. That will save me a lot of headaches I'm sure.
    AMD AthlonXP 2600+ Thoroughbred B @ 200x10.5
    Shuttle AN35N nForce2 Ultra 400
    2x512MB Kingston PC3200 (3-3-3)
    ATI Radeon 9600 Pro
    40GB WD ATA-100 8MB cache
    Creative 12X DVD Drive
    Memorex 52X CD-RW
    Running Windows XP Pro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •