OpenGL setup/linking - Dev-C++ 4.9.9.2

Dec 31, 2011 at 5:50pm
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?
Dec 31, 2011 at 5:52pm
You need to download GLUT or free glut. If you start a opengl project and use freeglut code then it does work. Google freeglut
Dec 31, 2011 at 6:31pm
I know that, but I don't know which files I need to link.
Dec 31, 2011 at 7:55pm
you need to put dll file to windows folder
Dec 31, 2011 at 8:11pm
I've set up the files, but I don't know what I need to link.
Dec 31, 2011 at 8:18pm
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).

P.S. http://cplusplus.com/articles/36vU7k9E/
Dec 31, 2011 at 8:19pm
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.
Dec 31, 2011 at 8:51pm
Ok, I've tried that in codeblocks, and I get the same errors that I have done before:

http://i41.tinypic.com/8ziuxx.png
Dec 31, 2011 at 9:01pm
Try glu32.lib as well
Dec 31, 2011 at 9:54pm
Nope, didnt work with glu32.lib. Same errors.
Dec 31, 2011 at 10:33pm
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.
Dec 31, 2011 at 11:10pm
@ModShop Which version should I be using? Can you give me a link please?

I tried with the project settings instead of the global settings but I still get the same errors.
Jan 1, 2012 at 2:08am
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).

For a MinGW version of glut, you can use this link:
http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/
(download the archive linked under "Setting Up GLUT for Win32 With MinGW")

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).
Last edited on Jan 1, 2012 at 2:26am
Jan 1, 2012 at 5:09am
@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.
Last edited on Jan 1, 2012 at 5:12am
Jan 11, 2012 at 5:55am
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!
Last edited on Jan 11, 2012 at 5:59am
Topic archived. No new replies allowed.