(在有人提到具有相同问题的类似问题之前,是的,我已经检查了我的路径中是否有空格之类的。这是我到项目根目录的路径:
C:\Users\sircode\Documents\GitHub\Univox\
所以我不确定还有什么可能导致它)
标题说明了要点。我试图让一个纯粹的 VSCode c++ / opengl 项目运行,但我一直在努力让 g++ 通过我的
tasks.json
文件查看文件。
我在任务文件中的参数如下:
"args": [
"-g",
"-std=c++17",
"-I./include",
"-L./lib",
"src/\\*.cpp",
"src/glad.c",
"-lglfw3dll",
"-o",
"${workspaceFolder}/prog.exe"
],
当我尝试单击
Run C/C++ File
任务时,它无法运行并在控制台中触发这些错误:
Starting build...
cmd /c chcp 65001>nul && C:\msys64\ucrt64\bin\g++.exe -g -std=c++17 -I./include -L./lib src/\*.cpp src/glad.c -lglfw3dll -o C:\Users\sircode\Documents\GitHub\Univox/prog.exe
cc1plus.exe: fatal error: src/\*.cpp: No such file or directory
compilation terminated.
cc1plus.exe: fatal error: src/glad.c: No such file or directory
compilation terminated.
Build finished with error(s).
我的文件夹结构应该适用于该命令,但事实并非如此,我完全不知道为什么。我尝试将父/项目根引用(../ 和 ./)附加到文件夹路径,但没有成功。
我不知道我是否只是错过了一些非常明显的东西,但我没有想法。
这是我的项目结构:
感谢 Drescherjm 的简单快速回答。
我只是在所有参考文献中缺少“${workspaceFolder}”。不知道为什么原始指南缺少这一点。
修复初始 src 文件夹后,include 和 lib 文件夹也被破坏,但相同的解决方案适用于它们。
针对 include、lib 和 src 文件夹调整了工作参数:
"args": [
"-g",
"-std=c++17",
"-I${workspaceFolder}/include",
"-L${workspaceFolder}/lib",
"${workspaceFolder}/src/*.cpp",
"${workspaceFolder}/src/glad.c",
"-lglfw3dll",
"-o",
"${workspaceFolder}/prog.exe"
],