OpenGL support come with many IDEs, programming environments and compilers. Likewise MSVS9 comes with built in support for OpenGL so that you can use all features of gl
and glu
libraries simply. To use glut
support we need to download and add the glut
support. Let us do both one by one.
OpenGL (gl
and glu
)

Hopefully you have already installed MS Visual Studio 2008 or MS Visual C++ 2008. If so, let us do the following,
- Create an empty C++ Win32 application.
- From File menu select New → Project (Ctrl+Shift+N).
- Select Win32 Project, enter a Name, and click OK.
- In the Wizard click Next, then check the box next to Empty Project, and click Finish.
- Add a new C++ source file
- Under the Project menu select Add New Item (Ctrl+Shift+A).
- Select C++ File (.cpp), enter a Name, and click OK.
- Link to the OpenGL libraries
Linking Libs - Under the Project menu select Project Properties (Alt+F7) at the bottom.
- Select Configuration Properties → Linker → Input from the navigation panel on the left.
- Select All Configurations from the Configuration drop-down box at the top of the dialog. This ensures you are changing the settings for both the Debug and Release configurations.
- Type “
opengl32.lib glu32.lib
” in Additional Dependencies and click OK.
- Now, you can start coding. You can download
GLDemo.cpp
to begin with a demo that, if executed(Cntrl+F5), will show a window with blue triangle.
GLUT
with a Win32 console application
Download and Install GLUT
Assuming, you already have MSVS9 installed, you have OpneGL libraries installed and placed in exact places. But, if one need to use the functionality of glut
library it is necessary to download and install the very library. Please, do the following:
- Download the original
GLUT
library from Nate Robins’ site - Unzip the download and copy files as instructed below,
glut.h
to the folderC:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl\
glut32.lib
to the folderC:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\
glut32.dll
to the folderC:\Windows\System32\
- You are now ready to use
GLUT
!
N.B.: For Visual Studio 2010 check later post, glut in MS Visual Studio 2010 (MSVS10)
Working With GLUT
Now, have your GLUT set up, you can work with GLUT and OpenGL in whatever way you like. Meanwhile, let me place a simple demo:
- From File menu select New → Project (Ctrl+Shift+N).
- Select Win32 Console Application, enter a Name, and click OK.
- In the Wizard click Next, then check the box next to Empty Project, and click Finish.
- Add new source file (
*.cpp
) from the project menu [Source File → Add → New Item → Visual C++ → Code → C++ File (.cpp)] enter a Name and click add - You can use a demo file from here (
GLUTdemo.cpp
). If execute, you will see a triangle to appear; you can move it left[j] and right[l] ward and rotate/stop rotate[r] and exit app[Esc]. - In a later post we will discuss coding in OpenGL and GLUT and make a simpler start-up demo, with short description on each line. [⇗]
It is all in short for now; I hope you this has been helpful. For introductory tutorial on programming OpenGL in C/C++ please try my next post in this category » Beginning Device-independent Graphics Programming with OpenGL (using GL, GLU & GLUT)
References
I would like to place some links that I found helpful, and also thank the authors hereby, as follow:
http://thoughtsfrommylife.com/article-748-OpenGL_and_Visual_Studio_Express_2008
http://www.opengl.org/
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=220142
http://sourceforge.net/projects/freeglut/files/freeglut/2.4.0/freeglut-2.4.0.tar.gz/download
http://www.xmission.com/~nate/glut.html
I faced some problem in using OpenGL libraries and GLUT library and eventually found some solution from the web. Hence I am posting this blog to share some help in one place that may help other guys and girls.
aita to just library add kora and open new file er tutorial…..
plz write abt how to code in opengl? or some documentation of gl functions, or some application code as like as “hello world”…thanks best of luck
LikeLike
The demos are of little help here and you get basic idea of OpenGL programming. I will try to do some more hello worlds or “how to”s.
This post is just a solution to a problem that has been troubling some other guys also.
LikeLike
Very Helpful.. thank you very much…
LikeLike
Thank you : )
LikeLike
😀
I’m glad
LikeLike
saved my time……..
LikeLike
😀
LikeLike
In order for this to work for VS2010, I had to modify:
Type “opengl32.lib glu32.lib” in Additional Dependencies and click OK.
to
Type “opengl32.lib; glu32.lib;” in Additional Dependencies and click OK.
Thanks for the tutorial!
LikeLike
thanks for the update 🙂
LikeLike
thanks nafSad and Mike Kusold
LikeLike
I’m using MSVS 2010, i’ve followed the tutorial, I input the additional dependancies as Mike K. suggested, but i’m getting these 2 errors:
error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup c:\Users\Jay\documents\visual studio 2010\Projects\GLUT test\GLUTtest\MSVCRTD.lib
error LNK1120: 1 unresolved externals c:\users\jay\documents\visual studio 2010\Projects\GLUT test\Debug\GLUTtest.exe
LikeLike
I’ve used the same way I mentioned on this post, but never encountered such error. May be you have missed something.
Plz, check if u have created an Empty Project and if it is a console application and not a Graphic one.
Please check Beginning Device-independent Graphics Programming with OpenGL (using GL, GLU & GLUT) for getting started.
Make sure the order of headers are correct, alteration of order often lead to error messages.
LikeLike
Also, check out this website: http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/14e85604-6929-4707-a22e-8cdf596926a6
LikeLike
Thanks Mike for helping with links.
I presume, the thread is a nice one.
LikeLike
Hi
Thats a real good tutorial. However GLUT doesn’t work yet.. I have MS visual Studio 9 and installed glut as mentioned . I open a new project in MS Visual Studio and don’t even have option of Win32 project. there is a console application or empty project option. How can i use GLUT in MS Visual studio?? pls help.
LikeLike
You can work with Console application, and it should be an Empty Project to run codes provided with my webnotes.
For problems with MSVS installation other fellows might help; I never had to face such problem though.
LikeLike
amazing !!…thanks a lot 🙂
LikeLike
when i try to compile GLUTdemo.cpp I got an error saying glut32.dll is missing hence cannot start … can somebody help me with that plz
LikeLike
If you are in MSVS9 (Visual Studio 2008) please, try to follow the steps explained in the blog. Ensure files are in exact directories. And ensure, that you are trying to compile a project and not a file
LikeLike
great instructions. thanks!
LikeLike
🙂
LikeLike
hi……
am having C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
instead of C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
will it work if i add those header file and library file?
LikeLike
For MSVS 10 this path will be ~v7.0~ instead of ~v6.0~
you may also read, https://ins.nafsadh.com/2010/08/20/glut-in-ms-visual-studio-2010-msvs10/
LikeLike
i tried but its telling dat i miss d glut32.dll file
its tellin me to reinstall the program
nd m usin msvstd2010
pls replyy soon
LikeLike
thanks alott….:-)
LikeLike
Thx buddy…..it is very very very much use-ful for me….:)
LikeLike
Thanks very much for this – significantly more useful than the decades old instructions on the official sites.
LikeLike
🙂
It is nice to know that you liked it.
LikeLike
Thanks your guide! It’s work great!
LikeLike
🙂
It is nice to know that it came to your help.
LikeLike
The mistake that I was making was that I was copying the dll files to the System32 folder when I was actually using a 64 bit system, so when I copied the dll files to the SysWOW64 folder the problem was fixed. Thanks for help!
LikeLike
i have unsuucessfull build error…..
unable to start programm
glut/glut/system.exe
file not specified
LikeLike
plz check if all filepaths are okay.
LikeLike
Very helpful indeed
LikeLike
I am glad, it came to your help.
LikeLike
“the system cannot find the file specified” this message popup when i debug… Can you help me out….?
LikeLike