c++ - Visual Studio Code - SFML libraries not found
问题描述
I'm trying to experiment with SFML in VScode, but the libraries aren't being found for me.
I've tried changing the c_cpp_properties.json
file to add the libraries to the includePath
, but they're still not being found.
This is the main class:
#include <iostream>
#include <Window.hpp>
#include <Graphics.hpp>
int main()
{
// create the window
sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
// run the program as long as the window is open
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
window.close();
}
// clear the window with black color
window.clear(sf::Color::Black);
// draw everything here...
// window.draw(...);
// end the current frame
window.display();
}
return 0;
}
Here's the properties file:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/Users/arnavchandra/Desktop/tic/SFML-2.5.1-macos-clang/include/SFML/"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
For #include <iostream>
, I'm getting this error:
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/arnavchandra/Desktop/tic/main.cpp).
For #include <Graphics.hpp>
, I'm getting this error:
cannot open source file "SFML/Window.hpp" (dependency of "Graphics.hpp")
When I run it, I get this error:
main.cpp:2:10: fatal error: 'Window.hpp' file not found
1 error generated.
解决方案
您应该尝试 putSFML-2.5.1-macos-clang/include/**
而不是SFML-2.5.1-macos-clang/include/SFML/
in includePath
。
推荐阅读
- python - 在 python 中压缩和过滤
- angular - 在 Angular 中设置全球时区
- javascript - 防止鼠标第四个和第五个按钮在浏览器历史记录中向后/向前导航?
- numpy - numpy 和 mathdotnet.com 之间的移动平均差异
- javascript - 如果其他按钮具有特定类,则切换按钮
- git - git push 不显示远程存储库中的更改
- python - Django formset动态无法添加表单
- scala - 使用在集群上具有不同版本的依赖项构建 jar
- apache-spark - 在内存受限的设置中运行 Spark
- testing - 如何使用 testWidgets 测试 Widget 的动态颜色