0

我正在尝试让 SFML 在 code::blocks 上工作,但每当我尝试测试示例代码时,我都会遇到错误。我按照http://www.sfml-dev.org/tutorials/2.0/start-cb.php的教程进行操作,但它似乎不起作用。

我不是很擅长这个,所以如果有人可以帮助它会很棒。

这是代码和错误的屏幕截图:http: //i39.tinypic.com/nbdysj.jpg

以下是错误:

obj\Debug\test.o||In function `main':|
C:\Users\Mads\Desktop\test\test.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
C:\Users\Mads\Desktop\test\test.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
C:\Users\Mads\Desktop\test\test.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
C:\Users\Mads\Desktop\test\test.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
C:\Users\Mads\Desktop\test\test.cpp|5|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\Users\Mads\Desktop\test\test.cpp|7|undefined reference to `sf::Color::Green'|
C:\Users\Mads\Desktop\test\test.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
C:\Users\Mads\Desktop\test\test.cpp|15|undefined reference to `sf::Window::close()'|
C:\Users\Mads\Desktop\test\test.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
C:\Users\Mads\Desktop\test\test.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
C:\Users\Mads\Desktop\test\test.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
C:\Users\Mads\Desktop\test\test.cpp|19|undefined reference to `sf::RenderStates::Default'|
C:\Users\Mads\Desktop\test\test.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
C:\Users\Mads\Desktop\test\test.cpp|20|undefined reference to `sf::Window::display()'|
C:\Users\Mads\Desktop\test\test.cpp|9|undefined reference to `sf::Window::isOpen() const'|
C:\Users\Mads\Desktop\test\test.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\Users\Mads\Desktop\test\test.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\test.o||In function `~CircleShape':|
C:\Users\Mads\Desktop\SFML-2.0\include\SFML\Graphics\CircleShape.hpp|42|undefined reference to `vtable for sf::CircleShape'|
C:\Users\Mads\Desktop\SFML-2.0\include\SFML\Graphics\CircleShape.hpp|42|undefined reference to `vtable for sf::CircleShape'|
C:\Users\Mads\Desktop\SFML-2.0\include\SFML\Graphics\CircleShape.hpp|42|undefined reference to `sf::Shape::~Shape()'|
||=== Build finished: 20 errors, 0 warnings ===|
4

2 回答 2

0

我有同样的问题,我必须做两个步骤才能让它工作。

1)手动编译SFML而不是使用打包版本。

2)在构建选项中将手动编译的版本添加到项目中。

在此之前,即使我按照文档中的描述指定了所有内容,我也会不断收到这些错误。

于 2013-08-06T13:44:46.907 回答
0

您应该将以下内容添加到您的 CB 项目文件 *.cbp 中:

<Linker>
       <Add library="GL" />
</Linker>
于 2016-10-17T16:35:27.830 回答