c++ - 使用 Visual Studio 构建错误

标签 c++ visual-studio visual-studio-2010 opengl glew

我有一个针对之前的 C++ 项目的解决方案。当我在 Visual Studio 中打开解决方案并尝试构建时,出现错误:

1>------ Build started: Project: Test Proj, Configuration: Release Win32 ------
1>Build started 9/19/2011 8:28:56 PM.
1>InitializeBuildStatus:
1>  Touching "Release\Test Proj.unsuccessfulbuild".
1>ClCompile:
1>  example1.cpp
1>c:\users\mycomp\downloads\stp\testp\code\Angel.h(38): fatal error C1083: Cannot open include file: 'GL/glew.h': No such file or directory
1>  InitShader.cpp
1>c:\users\mycomp\downloads\stp\testp\code\Angel.h(38): fatal error C1083: Cannot open include file: 'GL/glew.h': No such file or directory
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.85
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我必须更改项目的输入链接器设置以包含 glew32d.lib。这修复了它,并且它可以正确编译和运行。

但是,当我更改 example1.cpp(即使只是添加注释)时,我无法再构建它并收到此错误:

1>------ Build started: Project: Test Proj, Configuration: Release Win32 ------
1>Build started 9/19/2011 8:25:29 PM.
1>InitializeBuildStatus:
1>  Creating "Release\Test Proj.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  example1.cpp
1>c:\users\mycomp\downloads\stp\testp\code\Angel.h(38): fatal error C1083: Cannot open include file: 'GL/glew.h': No such file or directory
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.67
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

glew32d 仍在链接中,因此我不确定在哪里收到错误以及为什么无法构建

最佳答案

这不是链接器错误,而是编译错误。

c:\users\mycomp\downloads\stp\testp\code\Angel.h(38): fatal error C1083:...
                                         ^^^^^^^^^^^

我敢打赌 Angel.h 的第 38 行,你试图包含...

...Cannot open include file: 'GL/glew.h': No such file or directory
                             ^^^^^^^^^^^

...编译器找不到头文件。

您需要确保 OpenGL 头文件(无论哪个文件夹包含名为 GL 的文件夹,其中包含名为 glew.h 的文件)可供编译器使用;您可以将此文件夹添加到 C++ 项目属性中的“附加包含目录”中。

关于c++ - 使用 Visual Studio 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7478889/

相关文章:

asp.net - 无法加载文件或程序集

c++ - 聚合对象是否强制成为 IUnknown 引用?

c++ - #导入 : Cannot open file "soap12.h" for reading gSoap in VS 2010

c++ - QHostInfo问题

java - JNI : convert Primitive type to jobject Or SetObjectArrayElement of Object type after casting

c++ - 使用通用侵入式指针客户端进行引用计数

c++ - 为什么内存泄漏只发生在赋值运算符重载的情况下而不发生在复制构造函数中以及 copy-and-swap 习语如何解决它

c - 我无法在 C 中保持打开控制台

c# - 通过编程使用时,我的插入命令不会更改数据库

visual-studio - Visual Studio 生成事件宏 - 解决方案配置名称