【发布时间】:2020-04-07 04:02:39
【问题描述】:
您好,我一直在尝试通过使用 Visual studo 代码来学习 c++ SFML。 在观看了如何在 C++ 中安装 sfml 的教程后,我已经完成了所有设置。 但是,问题是当我尝试编译时它给了我这个错误: “main.cpp:2:10:致命错误:SFML/Graphics.hpp:没有这样的文件或目录”。 我已经阅读了许多指南,但似乎都没有工作。
这是我的代码:
#include <SFML/Graphics.hpp>
#include <iostream>
int main() {
sf::RenderWindow window(sf::VideoMode(1280,720),"Nareszcie");
while(window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type==sf::Event::Closed)
{
window.close();
}
window.clear();
}
}
return 0;
}
希望有人能帮我解决这个问题。
tasks.json:
{
"tasks": [
{
"type": "shell",
"label": "g++.exe build active file",
"command": "C:/mingw32/bin/g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:/mingw32/bin"
}
},
{
"type": "shell",
"label": "cpp.exe build active file",
"command": "C:\\mingw32\\bin\\cpp.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\mingw32\\bin"
}
}
],
"version": "2.0.0"
}
c_cpp_prperties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/SFML-2.5.1/include/**",
"C:/SFML-2.5.1"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/mingw32/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
【问题讨论】:
-
您使用什么构建系统以及您的编译器标志是什么?
-
我应该发送什么 .json 文件。
-
您需要为 SFML 添加包含目录。如何做到这一点取决于你如何编译你的项目。
-
添加了 json 文件
-
@super 我应该添加哪些目录?
标签: c++ visual-studio-code sfml