创建新文件时,它显示"<SFML/Graphics.hpp> no such file or directory"
On creation of a new file it shows "<SFML/Graphics.hpp> no such file or directory"
每当我在代码块中创建新文件或类并包含Graphics头或任何sfml头时,编译器都会说没有这样的文件或目录。
当我在单个文件程序上工作时工作正常,但当我创建一个新文件并将该文件包含在同一个项目中时,编译器开始显示错误。
显示如下错误:
E:codessfml_projectmain.cpp:1:29:致命错误:SFML/Graphics.hpp: No such file or directory
我甚至尝试再次安装SFML 2.1
并将所有文件链接到CodeBlocks,但这是没有用的。
请帮帮我,我已经试着找出这个错误2天了,但无法纠正。
我首先在代码块中创建了项目,其中包含main.cpp文件和代码
#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;
}
这个工作得很好,然后我在代码块中创建了一个新的类World和从file->new->class,并包含了一个文件SFML/Graphics.hpp
the World class looks like
World.hpp文件包含代码
#ifndef WORLD_HPP
#define WORLD_HPP
#include < SFML/Graphics.hpp >
class World
{
public:
World();
protected:
private:
};
#endif // WORLD_HPP
和World.cpp文件包含
#include "World.hpp"
World::World()
{
//ctor
}
此时只有编译器开始显示错误
E:codessfml_projectWorld.hpp:4:29:致命错误:SFML/Graphics.hpp: No such file or directory
所有的文件(World.hpp, World.cpp, main.cpp)都在同一个文件夹中
另外,尽管这看起来很傻,但请确保您已经安装了开发包。
在基于debian的操作系统中为:安装libsfml-dev
它与SFML的其余部分不同。我遇到了同样的问题,这是我的疏忽。编码快乐!
您的编译器显示为GCC。假设SFML/Graphics.hpp
确实在编译器的包含搜索路径,那么您的问题就来自于编码:
#include < SFML/Graphics.hpp >
代替:
#include <SFML/Graphics.hpp>
尖括号必须包含要搜索的header-name,没有别的了。如果他们把剩余空间围起来,那么剩余
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 什么是"#include <boost/functional/hash.hpp> "?
- 使用Vulkan hpp vk::enumerateInstanceVersion()会导致segfault
- EASTL矢量<向量<int>>连续的
- 如何将class.cpp和class.hpp编译为一个.o文件
- g++ -I 和 -L 命令来查找不起作用的 .hpp 文件
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- Gnuplot_i.hpp C++接口绘制局部变量而不是文件
- 致命错误:找不到'boost/uuid/uuid.hpp'文件
- BGL:当包含 random_spanning_tree.hpp 时,对strong_components的调用无法编译
- 造成致命错误:boost/fusion/iterator/equal_to.hpp 没有这样的文件或目录
- 无法使包含.hpp文件与其中的2个文件一起使用
- 在指向现有内存地址的 hpp 文件中声明成员函数的最佳方法
- 无法打开包含文件'Graphics.hpp'没有这样的文件或目录,Visual Studio的其他包含不起作用
- 编译器正在查找.当"实施"完全在"我的"中时的CPP文件.HPP文件
- 我的项目中某些仅标头文件不能包含使用 CMake 和 Vscode 的"SFML/Graphics.hpp"
- QtCreator使用CMAKE_C_FLAGS来解释C++(hpp)标头
- 如何正确使用hpp文件和cpp文件中的嵌套类
- 错误: C1083: 无法打开包含文件:"boost/asio.hpp": 没有此类文件或目录
- opencv 2.4.7在iOS错误背景_segm.hpp #include&lt; list&gt;未找到