我的Graphics.hpp文件似乎找不到Window.hpp文件。我试着用一个更具体的路径移动它,但我仍然得到错误'SFML/Window.hpp' file not found
,即使文件显然在那个文件路径中。我使用的是SFML 2.5.1_2
整个Graphics.hpp文件:
#ifndef SFML_GRAPHICS_HPP
#define SFML_GRAPHICS_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp> <---------- The error is right here
#include <SFML/Graphics/BlendMode.hpp>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/ConvexShape.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Glyph.hpp>
#include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/PrimitiveType.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/RenderStates.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderTexture.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Shader.hpp>
#include <SFML/Graphics/Shape.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Transform.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/Vertex.hpp>
#include <SFML/Graphics/VertexArray.hpp>
#include <SFML/Graphics/VertexBuffer.hpp>
#include <SFML/Graphics/View.hpp>
#endif // SFML_GRAPHICS_HPP
////////////////////////////////////////////////////////////
/// defgroup graphics Graphics module
///
/// 2D graphics module: sprites, text, shapes, ...
///
////////////////////////////////////////////////////////////
问题是,他们没有为g++编译器的非标准位置包含包含路径。要修复此问题,请尝试使用以下方法进行编译,将安装路径替换为安装路径:
g++ -c main.cpp -I<sfml-install-path>/include
这应该可以解决问题。看见https://www.sfml-dev.org/tutorials/2.5/start-linux.php了解更多信息。