无法使用 Visual Studio 代码中的 g++ 编译 SFML C++ 代码
Unable to compile SFML C++ code with g++ from Visual Studio Code
我正在尝试在 Visual Studio 代码中编译一些 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 库网站的示例代码)时,我从编译器收到这条消息:
Executing task: g++ main.cpp -o GUImeOfLife.exe -IC:C:\lib\SFML\include\SFML -LC:C:\lib\SFML\lib -lsfml-graphics -lsfml-window -lsfml-system
main.cpp:1:24: fatal error: Graphics.hpp: No such file or directory
compilation terminated.
The terminal process terminated with exit code: 1
(有问题的行就是 #include <Graphics.hpp>
)
我需要更改什么才能使其正常工作?
谢谢
来自您的配置文件
"-IC:C:\lib\SFML\include\SFML",
你提供的路径前面多了一个错误的C:
路径应该是
"-IC:\lib\SFML\include\SFML",
这个打字错误也是-L
选项的一部分。
我正在尝试在 Visual Studio 代码中编译一些 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 库网站的示例代码)时,我从编译器收到这条消息:
Executing task: g++ main.cpp -o GUImeOfLife.exe -IC:C:\lib\SFML\include\SFML -LC:C:\lib\SFML\lib -lsfml-graphics -lsfml-window -lsfml-system
main.cpp:1:24: fatal error: Graphics.hpp: No such file or directory compilation terminated.
The terminal process terminated with exit code: 1
(有问题的行就是 #include <Graphics.hpp>
)
我需要更改什么才能使其正常工作?
谢谢
来自您的配置文件
"-IC:C:\lib\SFML\include\SFML",
你提供的路径前面多了一个错误的C:
路径应该是
"-IC:\lib\SFML\include\SFML",
这个打字错误也是-L
选项的一部分。