window10 + visual sdudio 2015 13+ cmake 3.0 learnOpengl源码配置

本文档详细记录了在Windows 10环境下,使用Visual Studio 2015和CMake 3.0配置LearnOpenGL源码时遇到的编译失败问题。问题主要出现在dll文件复制过程中,由于多个工程尝试将文件复制到同一目录导致冲突。解决方法包括以管理员权限运行Visual Studio,修改项目后期生成时间设置,或者逐一编译并整体重新生成。
摘要由CSDN通过智能技术生成

下载源码

learnOpenGL的示例代码的read me 描述了windows、linux、mac不同平台的配置方法。
其中windows配置代码的方法:

All relevant libraries are found in /libs and all DLLs found in /dlls (pre-)compiled for Windows. The CMake script knows where to find the libraries so just run CMake script and generate project of choice.
Keep in mind the supplied libraries were generated with a specific compiler version which may or may not work on your system (generating a large batch of link errors). In that case it’s advised to build the libraries yourself from the source.

翻译过来就是人家是在特定visual studio版本编译的(2019)如果你本地编译有错误,需要在自己的平台重新编译。引用的库目录在/libs和 /dll目录下
Alt

learnOpenGL中文官网 link.

learnOpenGL源码 link.

生成sln工程

在源码目录下新建一个build文件夹用来生成编译的文件和工程文件。然后打开cmake选择源码目录和我们新建的build目录,我新建的目录是:C:\Users\你自己的用户名\Documents\project\learnOpenGL\learnOpenGL\LearnOpenGL-master\build,选择好目录后点击1生成此时会弹出选择平台,笔者是x64。然后点击2,3打开visual studio解决方案。
cmake配置平台界面

cmake配置界面
打开的工程

此时右键解决方案选择生成,等待编译。
编译
如果编译器没有报错,那恭喜你配置成功。我编译失败了
在这里插入图片描述

编译失败问题

我直接生成解决方案报错了,我的解决方法:
看了错误的原因是复制文件的时候多个工程复制到一个目录下,有冲突,因此根据编译失败信息,找到对应工程右键=》仅用于项目=》仅重新生成项目。然后再重新生成整个解决方案,如果还报错就按照上面的方法一直右键单独生成再整体编译。
错误信息:
在这里插入图片描述

17> Error copying file “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/dlls/ikpMP3.dll” to “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/bin/1.getting_started/Debug”.
17> Error copying file “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/dlls/irrKlang.dll” to “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/bin/1.getting_started/Debug”.

34> Error copying file “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/dlls/ikpMP3.dll” to “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/bin/2.lighting/Debug”.
31> Error copying file “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/dlls/ikpMP3.dll” to “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/bin/2.lighting/Debug”.
34> Error copying file “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/dlls/irrKlang.dll” to “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/bin/2.lighting/Debug”.
35> Error copying file “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/dlls/irrKlang.dll” to “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/bin/2.lighting/Debug”.
33> Error copying file “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/dlls/irrKlang.dll” to “C:/Users/xxx/Documents/project/learnOpenGL/learnOpenGL/LearnOpenGL-master/bin/2.lighting/Debug”.

解决方法:
1、右键visual studio管理员身份运行
在这里插入图片描述

2、右键项目属性”->“生成事件”->“后期生成时间”->“在生成中使用”->选择“否”。
在这里插入图片描述

需要运行那个工程就设置哪个工程,这种方法需要手动设置每个工程的后期生成时间。

还有一种方法是看错误信息单独编译一个项目然后整体重新编译,如此递归编译知道编译完成
在这里插入图片描述
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值