![](/img/trans.png)
[英]C++ code compiles in CentOS g++, but not in Visual studio 2008
[英]Unable to compile SFML C++ code with g++ from Visual Studio Code
我正在嘗試在 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}
{
"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-system
main.cpp:1:24: 致命錯誤: Graphics.hpp: 沒有這樣的文件或目錄編譯終止。 終端進程以退出代碼終止:1
(有問題的行只是#include <Graphics.hpp>
)
我必須改變什么才能使它工作?
謝謝
從您的配置文件
"-IC:C:\\lib\\SFML\\include\\SFML",
您提供的路徑在前面添加了一個額外且錯誤的C:
:。
路徑應該是
"-IC:\\lib\\SFML\\include\\SFML",
這個錯字也是-L
選項的一部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.