【发布时间】:2022-10-14 01:09:09
【问题描述】:
在我的 .c 文件中我有这个错误:
#include <stdlib.h>
#include <GL/glut.h> <<<fatal error: GL/glut.h: No such file or directory
#include <math.h>
我将 freeglut 库放在我的工作区文件夹中,并在我的 .vscode 文件夹中创建了 3 个 .json 文件,它们看起来像这样:
c_cpp_properties.json
{
"configurations": [
{
"name": "windows-clang-x64",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/freeglut-3.4.0/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/mingw64/bin/g++.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
启动.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/PorFavorreeeee/MoreTeste",
"program": "c:/PorFavorreeeee/MoreTeste/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
任务.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe arquivo de build ativo",
"command": "C:\\mingw64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compilador: C:\\mingw64\\bin\\gcc.exe"
}
]
}
我真的不知道该怎么做才能编译。我不知道错误是在我正在使用的编译器中还是在我在 Vscode 中配置它们的方式中,我最近开始使用 VScode 并且不太了解编译文件的方式。感谢您的帮助:)。
【问题讨论】:
-
您的
c_cpp_properties.json告诉 VSCode IntelliSense 环境在哪里可以找到 GL 文件。但是您不会在tasks.json文件中告诉编译器。您需要将-I(大写 i)传递给编译器,以告知它有关非标准包含目录的信息。
标签: c visual-studio-code opengl compiler-errors freeglut