C++ Qt creator 添加外部库(仍然:无法打开包含文件:'GL/glew.h')

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14742856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 18:39:19  来源:igfitidea点击:

Qt creator Adding external library (still: Cannot open include file: 'GL/glew.h')

c++qtqt4qt-creatorqt5

提问by lightrek

I followed the instruction:

我按照说明操作:

  1. In the Projects pane, open the project file (.pro).
  2. Right-click in the code editor to open the context menu and select Add Library....
  1. 在“项目”窗格中,打开项目文件 (.pro)。
  2. 在代码编辑器中右键单击以打开上下文菜单并选择添加库...。

Add Library

添加库

Then the following lines were added into the pro file:

然后将以下行添加到 pro 文件中:

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/D:/OpenGL/glew-1.5.4/lib/ -lglew32
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/D:/OpenGL/glew-1.5.4/lib/ -lglew32d

INCLUDEPATH += $$PWD/D:/OpenGL/glew-1.5.4/include
DEPENDPATH += $$PWD/D:/OpenGL/glew-1.5.4/include

However, I click the green triangle icon on the bottom left the run the program, still get the errors:

但是,我单击左下角的绿色三角形图标运行程序,仍然出现错误:

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

错误:C1083:无法打开包含文件:'GL/glew.h':没有这样的文件或目录

回答by user1418638

I had the same problem and I figured it out just now: You have to run qmake(build->run qmake) to validate changes in the pro file.

我遇到了同样的问题,我刚刚想通了:您必须运行 qmake(build->run qmake) 来验证 pro 文件中的更改。

回答by Kavin

INCLUDEPATH += D:/OpenGL/glew-1.5.4/include
LIBS += -Lc:D:/OpenGL/glew-1.5.4/lib -lname

Just add the above line in the .pro file.Then check it.

只需在 .pro 文件中添加上面的行。然后检查它。

回答by Moritz Jasper

Check if the desired files really exist under D:/OpenGL/glew-1.5.4/include. I.e. is there a folder named GL and inside it a file named glew.h?

检查所需的文件是否确实存在于D:/OpenGL/glew-1.5.4/include. 即有一个名为 GL 的文件夹,里面有一个名为 glew.h 的文件吗?

Then try to remove the $$PWD/part from the paths.

然后尝试$$PWD/从路径中删除该部分。

If this doesn't help replace the generated lines with just those two lines:

如果这不能帮助仅用这两行替换生成的行:

LIBS += -L$$quote(D:/OpenGL/glew-1.5.4/lib/) -lglew32
INCLUDEPATH += $$quote(D:/OpenGL/glew-1.5.4/include)

回答by Abdennour TOUMI

  1. Open .profile with Editor
  2. Add directory of library in INCLUDEPATH +=section
  1. .pro用编辑器打开文件
  2. INCLUDEPATH +=节中添加库目录

enter image description here

在此处输入图片说明

 Append ` \` at the end of library path 
  1. Go to Build > Run qmake
  1. Build > Run qmake

enter image description here

在此处输入图片说明

  1. Check if library has been included .
  1. 检查库是否已包含。