C++无法在#include(SFML)中找到文件夹/文件
我找不到任何有效的东西,也不知道该去哪里。任务很简单,只需将SFML作为我的C ++文件中的库,但是每次尝试时,我都会出现某种错误。我正在使用SFML的示例代码:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
这是我的C_CPP_Properties.json文件:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\SFML-2.5.1\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\mingw64\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
看起来很简单,但是我无法弄清楚我在做什么错。我正在使用Mingw 64位,以及匹配的SFML版本。我正在用vScode进行编码,其中包括c/c ++扩展名和代码运行器(也尝试手动编译)。我已将mingW64和sfml bin路径同时添加到环境变量路径中。我是C ++的新手(较早的Python)。
编辑
要回答一些问题,目录确实包括正确的文件,这就是为什么我如此困惑的原因。我试图为 /切换\,但没有工作: /。错误(令人尴尬的我忘记了)是:
testing.cpp:1:10: fatal error: SFML/Graphics.hpp: No such file or directory
I cannot find anything that works, and I don't know where to go. The task is quite simple, to just include SFML as a library in my C++ file, but every time I try, I get some sort of error. I am using the sample code from SFML:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
And this is my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\SFML-2.5.1\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\mingw64\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
It seems so simple, and yet I just can't figure out what I'm doing wrong. I am using MinGW 64 bit, and the matching SFML version. I am coding in VSCode with extensions such as the C/C++ extension and code-runner (have tried to compile manually as well). I have added both the MinGW64 and SFML bin path to Enviroment variables path. I am new to C++ (Python earlier).
Edit
To answer some questions, the directory does include the correct files, which is why I am so confused. And I tried to switch the \ for /, but didn't work:/. And the error (embarrassing I forgot it) is:
testing.cpp:1:10: fatal error: SFML/Graphics.hpp: No such file or directory
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论