VS2019+win10x64+OpenGL安装流程
课程要求安装OpenGL,老师给的教程是这个https://heavenkong.blogspot.com/2018/03/opengl-installation-of-opengl-with.html
有亿、、麻烦
写在前面:
x64操作系统一定复制64位的lib和dll文件!!!!
步骤如下:
1. 安装Visual Studio 2019
创建一个空项目
解决资源管理器-源文件,新建cpp文件。(这样项目右键打开,属性才有C/C++)
默认路径是C:\Users\celia\source\repos\CGOpenGLExample
2. 下载GLFW http://www.glfw.org/download.html 64-bit Windows binaries
解压
include文件夹复制到C:\Users\celia\source\repos\CGOpenGLExample\CGOpenGLExample
lib-vc2019文件夹复制到上述路径,重命名为lib
3. 下载 GLEW http://glew.sourceforge.net/ windows 32-bit and 64-bit
解压
include文件夹复制到C:\Users\celia\source\repos\CGOpenGLExample\CGOpenGLExample
glew-2.1.0\lib\Release\x64 文件夹下两个文件复制到项目目录的lib文件夹下
glew-2.1.0\bin\Release\x64 文件夹下的glew32.dll复制到项目目录的lib文件夹下
4. 下载 FreeGLUT https://www.transmissionzero.co.uk/software/freeglut-devel/ Download freeglut 3.0.0 for MSVC
解压
include文件夹复制到C:\Users\celia\source\repos\CGOpenGLExample\CGOpenGLExample
freeglut\lib\x64文件夹下freeglut.lib复制到项目目录的lib文件夹下
freeglut\bin\x64文件夹下freeglut.dll复制到项目目录的lib文件夹下
5. 将64位的freeglut.dll, glew32.dll, glfw3.dll文件放在C:\Windows\System32和C:\Windows\SysWOW64中
(可能只放32位的文件夹就可以了)
6. VS中项目单击右键,打开属性
附加包含目录-添加 ./include
链接器-常规-附加库目录 ./lib
链接器-输入-附加依赖项 freeglut.lib;glew32.lib;glfw3.lib;OpenGL32.lib;
DONE!
安装过程中遇到问题:
1. 属性中没有C/C++
解决:需要在源文件下新建cpp文件,可空白
2. error LNK1104: 无法打开文件xxxxxxx
解决:可能是复制文件时复制了32位的,或者./lib写错了
3. 运行测试代码,弹窗显示应用程序无法运行
解决:在C:\Windows\System32中放64位的freeglut.dll, glew32.dll, glfw3.dll