我正在尝试在Visual Studio Code中编译一些C ++代码,但是我想使用SFML库,由于某种原因,它只是找不到我的库。我正在使用c / c ++扩展,其中的配置如下所示
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**", "C:\\lib\\SFML\\include\\**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\TDM-GCC-64\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4}
在this other question之后,我已经配置了一个任务,这给了我类似的东西
{
"version": "2.0.0",
"tasks":
[
{
"label": "Compilation",
"type": "shell",
"group": "build",
"command": "g++",
"args":
[
"main.cpp",
"-o",
"GUImeOfLife.exe",
"-IC:C:\\lib\\SFML\\include\\SFML",
"-LC:C:\\lib\\SFML\\lib",
"-lsfml-graphics",
"-lsfml-window",
"-lsfml-system"
],
"problemMatcher": "$gcc"
}
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}}
但是,当我在自己的代码上运行任务(仅是SFML库网站上的示例代码)时,我从编译器收到此消息:
执行任务:g ++ main.cpp -o GUImeOfLife.exe -IC:C:\ lib \ SFML \ include \ SFML -LC:C:\ lib \ SFML \ lib -lsfml-graphics -lsfml-window -lsfml-系统
main.cpp:1:24:致命错误:Graphics.hpp:没有此类文件或目录 编译终止。 终端进程终止于退出代码:1
(有问题的行就是#include <Graphics.hpp>
)
要使其正常运行,我需要更改什么?
谢谢
答案 0 :(得分:0)
从您的配置文件
"-IC:C:\\lib\\SFML\\include\\SFML",
您提供的路径前面加了一个错误的C:
。
路径应为
"-IC:\\lib\\SFML\\include\\SFML",
此 typo 也是-L
选项的一部分。