Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML project not building. (CodeBlocks)  (Read 2784 times)

0 Members and 1 Guest are viewing this topic.

Ispira

  • Newbie
  • *
  • Posts: 2
    • View Profile
SFML project not building. (CodeBlocks)
« on: May 27, 2013, 10:24:22 pm »
So, I'm yet another CodeBlocks user who is having trouble...
I've looked through the forums and I don't see anyone having the same problem though.

I've followed along with this tutorial: http://www.sfml-dev.org/tutorials/2.0/start-cb.php
completely, I've even tried switching to using static SFML.

I'm using the exact code from the tutorial:
#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;
}
 

I get the following errors:
obj\Debug\src\main.o||In function `main':|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|7|undefined reference to `sf::Color::Green'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|15|undefined reference to `sf::Window::close()'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|19|undefined reference to `sf::RenderStates::Default'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|20|undefined reference to `sf::Window::display()'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|9|undefined reference to `sf::Window::isOpen() const'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|5|undefined reference to `sf::RenderWindow::~RenderWindow()'|
C:\Users\Ryan\CPP Projects\b0x3l\src\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\src\main.o||In function `ZN2sf11CircleShapeD1Ev':|
C:\Program Files (x86)\CodeBlocks\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\Program Files (x86)\CodeBlocks\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
C:\Program Files (x86)\CodeBlocks\SFML\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `sf::Shape::~Shape()'|
||=== Build finished: 20 errors, 0 warnings (0 minutes, 0 seconds) ===|
 

I'm using:
CodeBlocks 12.11 (using inbuilt MinGW)
Windows 7 Home Premium x64
static SFML, set up how the tutorial said to (Same errors occur under dynamic)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML project not building. (CodeBlocks)
« Reply #1 on: May 27, 2013, 10:33:54 pm »
What libraries did you specify at the linker?

By the way, the forum is full of "undefined reference" error messages, you can hardly miss them ;)
« Last Edit: May 27, 2013, 10:35:37 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ispira

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SFML project not building. (CodeBlocks)
« Reply #2 on: May 27, 2013, 10:41:20 pm »
I've linked:
sfml-graphics-s
sfml-window-s
sfml-audio-s
sfml-system-s

And I didn't see anyone with the exact errors..must have not been looking hard enough :/ sorry.
nonetheless I still need help getting this fixed...

Ivan

  • Newbie
  • *
  • Posts: 32
  • IT geek
    • View Profile
Re: SFML project not building. (CodeBlocks)
« Reply #3 on: May 29, 2013, 11:34:41 am »
In Code:Blocks 12.11 with MinGW you need to use the GCC 4.7 TDM (SJLJ) - 32 bits SFML version, not DW2. Check what version are you using. This code works perfect in my Code:Blocks with SJLJ version.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML project not building. (CodeBlocks)
« Reply #4 on: May 29, 2013, 11:40:08 am »
You should upload your project file on the forum, it will be faster than asking a lot of questions to figure how you configured your project.

Quote
In Code:Blocks 12.11 with MinGW you need to use the GCC 4.7 TDM (SJLJ) - 32 bits SFML version, not DW2. Check what version are you using. This code works perfect in my Code:Blocks with SJLJ version.
Version mismatch would cause the app to crash. Such linker errors are rather caused by an incorrect project configuration.
Laurent Gomila - SFML developer