具有 Code::Blocks - "undefined reference to sf::Texture::getSize()" 的 SFML

SFML with Code::Blocks - "undefined reference to sf::Texture::getSize()"

我使用本教程 http://www.sfml-dev.org/tutorials/2.0/start-cb.php 将 SFML 添加到我的 Code::Blocks 项目中,但我遇到了这样的错误:

undefined reference to sf::Texture::getSize() const
undefined reference to sf::Sprite::Sprite()
undefined reference to sf::Sprite::setTexture(sf::Texture const&, bool)

以下是我的设置的屏幕截图:

内衬设置:

编译器的搜索目录:

链接器的搜索目录:

编译器设置:

||=== Build: Release in Space (compiler: GNU GCC Compiler) ===|
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Sprite::Sprite()'
 undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
 undefined reference to `sf::Transformable::setPosition(float, float)'
 undefined reference to `sf::Sprite::Sprite()'
 undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
 undefined reference to `sf::Transformable::setPosition(float, float)'
 undefined reference to `sf::RenderStates::Default'
 undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
 undefined reference to `vtable for sf::Sprite'
 undefined reference to `vtable for sf::Sprite'
 undefined reference to `sf::Transformable::~Transformable()'
 (.text$_ZN2sf6SpriteD1Ev[__ZN2sf6SpriteD1Ev]+0x3e)
undefined reference to `vtable for sf::Sprite'
 (.text$_ZN2sf6SpriteD1Ev[__ZN2sf6SpriteD1Ev]+0x45)
undefined reference to `vtable for sf::Sprite'
 (.text$_ZN2sf6SpriteD1Ev[__ZN2sf6SpriteD1Ev]+0x57)
 undefined reference to `sf::Transformable::~Transformable()'|
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined references to `sf::Texture::getSize() const' follow
 undefined reference to `sf::Clock::Clock()'
 undefined reference to `sf::seconds(float)'
 undefined reference to `sf::Time::Time()'
 undefined reference to `sf::operator<(sf::Time, sf::Time)'
 undefined reference to `sf::Time::Zero'
 undefined reference to `sf::Time::Zero'
 undefined reference to `sf::Clock::restart()'
 undefined reference to `sf::operator+=(sf::Time&, sf::Time)'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Sprite::Sprite()'
 undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
 undefined reference to `sf::Transformable::setPosition(float, float)'
 undefined reference to `sf::Sprite::Sprite()'
 undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
 undefined reference to `sf::Transformable::setPosition(float, float)'
 undefined reference to `sf::RenderStates::Default'
 undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates  const&)'|
 undefined reference to `vtable for sf::Sprite'
 undefined reference to `vtable for sf::Sprite'
 undefined reference to `sf::Transformable::~Transformable()'
 undefined reference to `sf::Sprite::getGlobalBounds() const'
 undefined reference to `sf::Sprite::getTextureRect() const'
 undefined reference to `sf::Transformable::getScale() const'
 undefined reference to `sf::Transformable::getTransform() const'
 undefined reference to `sf::Sprite::getTextureRect() const'
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

我想我明白了你的问题。我怀疑您需要从此处下载 SFML GCC 4.7 TDM (SJLJ) - 32 位 http://www.sfml-dev.org/download/sfml/2.1/ - 您可能使用了错误版本的库。