SFML tutorial not even working - c++

I installed SFML on codeblocks with their tutorial, following it step by step. Everything has been checked and done correctly, yet their sample program is not even building correctly. It seems that codeblocks cannot even find the basic functions of SFML.
What did I miss?
Error log :
( http://i.imgur.com/eaGz9HK.jpg )
My code :
#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;
}

It's very strange to give a library location -L and then explicitly link to the exact library. So, instead of giving the full path to the library, just give it's name. So, instead of ..\..\..\..\..\LOGICIELS\CodeBlocks\SFML\libs\libsfml-graphics-s-d.a just say sfml-graphics-s-d. Do this for all libraries
When you see -L..\..\..\..\..\..\LOGICIELS\CodeBlocks\SFML\lib you are telling the compiler (linker) where to find the libraries. The convention with libraries is that they are prefaced with lib and followed by .a. So, change you library linkage to just the name of your library, sans lib and .a
so, after obj\Debug\main.o, it should be sfml-grphics-s-d sfml-window-a-d sfml-system-a-d sfml-main-d

Related

SFML Unresolved external symbol (LINKER FAIL)

#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 e;
while (window.pollEvent(e))
{
if (e.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
I am not sure, why my program doesn't work. I tried to write libraries in input in Linker settings, but still not working. Also I defined SFML_STATIC for preprocessor heading, however I'm not sure do I need this or not.
I want to my code working. Everything was explained above.
perhaps run your program in both debug and release mode. then copy the bin/dll files over to those folders. also remove SFML_STATIC and you should be good to go, if youre using debug mode be sure to add -d to the linker input! hope this helps.
and also be sure youre using x86 version. you really shouldnt touch x64 unless you have some very specific apps you have to make.

SFML 2.1 program compiles but fails to run

I'm using SFML 2.1 (SJLJ) for Windows / GCC (32bit) and am building the project in CodeBlocks 10.05.
I'm trying to run the following code and it crashes. It builds smoothly however.
#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;
}
Many may recognize that this is taken directly from the SFML 2.1 tutorial site so I doubt there is anything wrong with the code. I've followed all instructions carefully but I have no clue what's causing it.
Some screenshots showing the build options and the actual error output are provided below:
I had no idea what was wrong specifically but upgrading to CodeBlocks 13.12 fixed the issue for me. It compiles perfectly now!

SFML Tutorial not up to date?

I've followed this tutorial to the letter in order to set up SFML 2.0 with Visual Studio Express 2012: http://www.sfml-dev.org/tutorials/2.0/start-vc.php
For some reason though I get 16 Unresolved LNK Errors. I am not sure what I am doing wrong. I follow the tutorial to the letter. At the point about using Static or Dynamic libraries I didn't add for example sfml-audio-s.lib I just added sfml-audio.lib as first advised.
This is the code the tutorial use as well:
#include <SFML\Graphics.hpp>
using namespace sf;
int main()
{
RenderWindow window(VideoMode(200,200), "SFML Works!");
CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while(window.isOpen())
{
Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
Is this tutorial just outdated or is it just me doing something horribly wrong?
LNK2019 is a Linker Error which can mean two things:
you didn't install the libraries correctly and/or didn't tell visual studio about these files
you are using code which uses another version of that library
You seem to use SFML2.0 since pollEvent() doesn't exist in v1.6.
Make sure you are using the right version and did configure Visual Studio correctly.

SFML 2.0 Crashing (Error on window-d-2

Using Code::Blocks, W7, Ati Card
I have this silly problem, I tried to compile a sample program from SFML website - http://www.sfml-dev.org/tutorials/2.0/start-cb.php
Everything set correctly, I think. When I start (Build and run) It throws out a crash, when looking into crash details it points out window-2-d.
All the .dll files are in the project directory, obviously a dynamic build.
RC from the website, for version 2.0 (I couldn't use 1.6 anyway because of ATI bug)
Tried to use this code to run it
#include <iostream>
#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;
}
Help?
If you're using the latest Code::Blocks version, which includes GCC 4.7.1, then you have to recompile SFML on your own (or use my Nightly Builds), because the ones provided are only for GCC versions < 4.7.x.
I couldn't use 1.6 anyway because of ATI bug
SFML 2 is better anyways, so don't worry.

Undefined symbol - Symbol lookup error

I am trying to compile the SFML 2.0 tutorial with Eclipse. The program compiles fine, but when I run it I get the following error:
/home/eXistys/workspace/SFML/Debug/SFML: symbol lookup error: /home/eXistys/workspace/SFML/Debug/SFML: undefined symbol: _ZN2sf12RenderStates7DefaultE
Under GCC C++ Compiler > Includes, I have:
/home/eXistys/SFML/include
and under GCC C++ Linker I have:
`sfml-graphics
`sfml-window
`sfml-system
What could this be? Google gives no results, SFML forums gives nothing useful and I can't find anything truly related on stackoverflow.
Here's the code I compiled successfully (the source code of this tutorial):
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(300, 200), "SFML works!");
sf::Text text("Hello SFML");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
window.display();
}
return 0;
}
I downloaded the latest snapshot of SFML 2.0 from here: https://github.com/LaurentGomila/SFML
Kind regards,
What you are missing is sf::RenderStates::Default. It is declared in RenderStates.cpp, which should be part of sfml-graphics. Are you sure, that sfml-graphics is linking with your program? Is rpath set correctly? I assume that you are building program executable and not a shared library, right? Have you tried to do LD_PRELOAD=/path/to/sfml-graphics/lib.so /path/to/program