在Visual Studio 2010 编译OpenGL程序(摘抄英文)
2011-04-19 09:49
645 查看
Compiling OpenGL Progams at Home Using Visual Studio
Windows does not include GLUT standard, like the lab machines in MLH 301 do. Thus, getting your OpenGL programs to compile and run at home is slightly more difficult. However by following the following steps, you should be able to figure out how to make it work:Download GLUT
Unzip the file.
Put the file "glut32.dll" into the system path.
This can be in the same directory as your executable file.
On Windows XP or earlier, this can be in "C:/WINDOWS/system32"
Or you can create a directory like "C:/DLLs", put the file in this directory and change your system path to include this new directory.
Do this by opening Control Panel -> System, clicking on "Advanced System Settings", followed by "Environment Variables", and editing the "Path" variable.
Put the file "glut.h" into the standard Visual C++ include directoy
(For Visual Studio 2010, this should be: "C:/Program Files/Microsoft SDKs/Windows/v7.0A/include/gl")
(For Visual Studio 2008, this should be: "C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include/gl")
(For Visual Studio 2005, this should be: "C:/Program Files/Microsoft Visual Studio.NET/Vc7/PlatformSDK/Include/gl")
You've got the right directory if you see a copy of "gl.h"
Put the file "glut32.lib" into the standard Visual C++ library directory
(For Visual Studio 2010, this should be: "C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib")
(For Visual Studio 2008, this should be: "C:/Program Files/Microsoft SDKs/Windows/v6.0A/Lib")
(For Visual Studio 2005, this should be: "C:/Program Files/Microsoft Visual Studio.NET/Vc7/PlatformSDK/lib")
There should be lots of .lib files here, including "opengl32.lib" and "glu32.lib".
Make sure your Visual C++ project links in the GLUT/gl/glu libraries (see also this page). This is located in:
Menu: "Project -> (your-project-name) Properties"
Tab: "Configuration Properties -> Linker -> Input"
Under "Additional Dependancies", add "glut32.lib glu32.lib opengl32.lib"
#include < GL/glut.h > in your program.
Note: This needs to come after you #include < stdio.h > and < stdlib.h >.
Note: This needs to come before you #include < GL/gl.h >.
Also note that glut.h includes gl.h for you (so you need not explicitly #include < GL/gl.h >).
You should not include windows.h or any other Windows-specific header files, no matter what you may read on random forum postings!
If you get compilation errors because of multiple conflicting definitions of "exit()", then "stdio.h" and "glut.h" have been #include'd in the wrong order. You may fix this by:
Reordering your #include files (see step #7). This is the "right" way.
Add "#define GLUT_DISABLE_ATEXIT_HACK" to glut.h on the line immediately after the first "#if defined(_WIN32)".
If you happen to have a 64-bit version of Windows and Visual Studio, make sure you compile a 32-bit executable.
相关文章推荐
- Visual Studio 2010编译Python扩展程序报error: Unable to find vcvarsall.bat
- 32位XP下visual Studio 2010编译64位程序
- 【MFC】Windows 用Visual studio 2010 编译出来的MFC 程序,在平板电脑上无法使用长按来弹出右击菜单
- OpenGL学习-------visual studio 2010配置和第一个OpenGL程序讲解
- 关于Visual Studio 2013 编译 multi-byte character set MFC程序出现 MSB8031 错误的解决办法
- “NeHe's OpenGL 程序框架”编译成功
- 在Visual Studio 2005/2008中编译C/C++程序
- 编译OpenGL程序遇到的一个奇怪问题
- 带你玩转Visual Studio——命令行编译C/C++程序
- 配置自己的OpenGL库,glew、freeglut库编译,库冲突解决(附OpenGL Demo程序)
- c++学习笔记(1)——环境搭建、经典教程推荐及 Visual Studio 2005/2008中如何编译和运行C++程序
- Visual Studio 2010工程项目中添加预编译宏
- Visual Studio 2010中的C++程序调用matlab程序代码 混合编程
- VS2010纯静态编译QT4.8.0,实现VS2010编译调试Qt程序,QtCreator静态发布程序
- 【Visual Studio 2010】访问 PostgreSQL 数据库的libpqxx4.0.1编译
- C#使用_如何在没有装VS(Visual Studio)的机器上编译运行C#程序
- Visual Studio 2013 编译C程序
- 使用Visual Studio 2010编译Qt
- 关于Visual Studio 2013 编译 multi-byte character set MFC程序出现 MSB8031 错误的解决办法
- visual studio 2010编译gdal1.8