gpt4 book ai didi

c++ - 将 gcc 与 Netbeans 一起使用

转载 作者:行者123 更新时间:2023-11-28 00:05:16 27 4
gpt4 key购买 nike

我想学习使用着色器,因此在 Netbeans(版本 8.0.2)上创建了一个新的 C++ 项目。

我想包括本教程中所述的 GLFW 和 GLEW 库:http://www.learnopengl.com/#!Getting-started/Creating-a-window

我想我成功地包含了这些库。 (Netbeans 在使用 #include <GL\glew.h>#include <GLFW\glfw3.h> 时没有显示错误,所以我认为它找到了所有文件)。

我的系统:Windows 10 x64,通过 cygwin 使用 GNU gcc 编译器

问题来了:当我尝试运行该程序时,有以下输出:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/Users/Erik/programming/projects/FinallyShaders'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/finallyshaders.exe
make[2]: Entering directory '/cygdrive/c/Users/Erik/programming/projects/FinallyShaders'
mkdir -p build/Debug/Cygwin-Windows
rm -f "build/Debug/Cygwin-Windows/main.o.d"
gcc -c -g -include /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL -include /cygdrive/C/Users/Erik/programming/Libraries/glfw-3.1.2.bin.WIN32/glfw-3.1.2.bin.WIN32/include/GLFW -MMD -MP -MF "build/Debug/Cygwin-Windows/main.o.d" -o build/Debug/Cygwin-Windows/main.o main.c
cc1: fatal error: /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL: No such file or directory
compilation terminated.
nbproject/Makefile-Debug.mk:66: recipe for target 'build/Debug/Cygwin-Windows/main.o' failed
make[2]: *** [build/Debug/Cygwin-Windows/main.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/Erik/programming/projects/FinallyShaders'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/Erik/programming/projects/FinallyShaders'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 722ms)

它似乎失败了,因为 gcc 编译器(或者更准确地说是它的 cc1 部分)找不到库的 include-directory。但是,如前所述,路径是正确的。使用 cd <the path that cannot be found> 时一切正常,cygwin 找到了这条路径。

(到目前为止,我的程序除了调用 printf() 什么都不做,这应该不是问题所在)

有人知道这可能意味着什么以及如何解决这个问题吗?

谢谢你的帮助

埃里克·布伦德尔

最佳答案

您失败的编译器命令行是:

gcc -c -g \
-include /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL \
-include /cygdrive/C/Users/Erik/programming/Libraries/glfw-3.1.2.bin.WIN32/glfw-3.1.2.bin.WIN32/include/GLFW \
-MMD -MP -MF "build/Debug/Cygwin-Windows/main.o.d" \
-o build/Debug/Cygwin-Windows/main.o main.c

修复报告的错误:

cc1: fatal error: /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL: No such file or directory

应该是:

gcc -c -g \
-I/cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL \
-I/cygdrive/C/Users/Erik/programming/Libraries/glfw-3.1.2.bin.WIN32/glfw-3.1.2.bin.WIN32/include/GLFW \
-MMD -MP -MF "build/Debug/Cygwin-Windows/main.o.d" \
-o build/Debug/Cygwin-Windows/main.o main.c

您混淆了编译器选项 -include-I。参见 the documentation ofthese options这是一个 pretty good introductory tutorial to the use of GCC

在 Netbeans 项目属性中,包含搜索目录应该是在 Build -> C Compiler -> Include Directories 中输入,而不是 Include Headers

关于c++ - 将 gcc 与 Netbeans 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36084470/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com