I'm starting to learn OpenGL, but I keep getting errors when I try to compile the example code that I download. The errors are linking errors. What files do I need to link?
Do you have any .a or .lib files for OpenGL? If you don't, then you don't have the files you need. If you do, then you need to tell the linker where to find those files (usually under Project Settings or some equivalent).
There are ussually 3 parts to installing an external library:
1. DLL file
2. Library file
3. Header file
If you don't have the DLLs installed, you'll get runtime errors, not linking errors. Therefore this isn't your problem.
If you don't have the headers installed, you'll get compiling errors, not linking errors. Therefore this isn't your problem.
Your problem lies with your library files. Let's say that you are using freeglut. Make sure that you:
a) Have freeglut.lib and opengl.lib available in your library directory (for me in Windows 7 with VS 2010 it's in C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib).
b) Have freeglut.lib and opengl.lib linked in your project. For me with VS 2010, right click on the project, choose Properties > Linker > Input > Additional Dependencies > Edit and add freeglut.lib and opengl.lib to the window.
If you are using Glut, then use glut32.lib instead of freeglut.lib.
Why are you editing the global settings? Try editing the project settings (Right click on project name -> Build Options -> Linker Settings). Also make sure that you have the correct versions of the files your linking against.
That you're linking .lib files indicates that you're trying to link libraries intended for VS.
The libraries for glu32 and opengl32 already come with MinGW, so link those two (don't specify a path).
Drop the header file into your include/GL folder, libglut32.a in your lib folder (then link "glut32") and the dll somewhere where your program can find it (in your system folder or your application's folder).
@Athar I got it to compile now, but I get an error that says: "The program can't start because glut32.dll is missing from your computer. Try reinstalling the program to fix this problem."
Edit: Never mind, I got it to work :D Thanks for the help.
This is for Dev-C++
You need
libgdi32.a
libglu32.a
libglut32.a
libopengl32.a
libwinmm.a
Thats what i used for the linkers, I hoped this helped!
How to get GLUT:
Start a random Dev.
Find Tools in the bar on top.
Click "Check for updates/Packages..."
Change devpak server to "devpak.org Community Devpaks".
CLICK "CHECK FOR UPDATES"
Goto groups and find OpenGL
Find one thats named "GLUT" and is version 3.7.6+ and download selected!
HOPE THIS IS HELPFUL BECAUSE IT TOOK ME A LONG TIME TO FIGURE OUT!