SFML woes

Trying to get SFML to work using the Code::Blocks IDE.

I thought I followed the instructions at
http://www.sfml-dev.org/tutorials/2.3/start-cb.php

However when I ran the test example,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#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 this pop up window,

TestCode1:exe - Entry Point Not Found

The procedure entry point_ZSt24_throw_out_of_rang_fmtPKcz could not be located in the dyamic link library libstdc++-6.dll


Any suggestions would be welcome.

My background is a self taught programmer using the more advanced language of BASIC where you just type in the program and run it with no convoluted setups required. I have also used c++ succesfully with code::blocks using the console as input/output. Trying to get graphic libraries to work with a c++ program is doing my head in!!

Last edited on
Welcome to "DLL Hell". You're linking to a different version of the standard C++ library then what your project is expecting. Do you see that big orange box at the top of the page you linked us to? That is your problem in a nutshell. Compiling SFML yourself would be best, but there are other ways like placing a copy of the correct version of that DLL file in your project folder.
I always get frustated by SFML, so I changed libraries to Godot! lol
@Computergeek01
The libgcc_s_dw2-1.dll and libgcc_s_sjlj-1.dll are both in the MinGW/bin folder.
If I remember correctly (while back now) I installed MinGW along with Code::Blocks.

what version of sfml are you using, and what version of mingw. I just visited the codeblocks website and it looks like they updated the compiler that comes with codeblocks to tdm gcc 4.9.2 32bit SJLJ, since the last time i was there . It doesn't look like sfml has pre built binaries for this compiler. Which means your only option may be to build sfml yourself.


[Edit]
if you don't know the version of your compiler then open up a command prompt and type gcc --version
Last edited on
You need to link sfml-main.lib, you can read about it just above the green circle picture in setting up visual studio article. Probably she just forgot about it here.
Last edited on
Read the thread, He is using Code::Blocks, not Visual Studio
"Probably she just forgot about it here". What do you think I meant by here?

From sfml-dev.org: "If you chose to create a "Windows application" project, the entry point of your code has to be set to "WinMain" instead of "main". Since it's Windows specific, and your code would therefore not compile on Linux or Mac OS X, SFML provides a way to keep a standard "main" entry point in this case: link your project to the sfml-main module ("sfml-main-d.lib" in Debug, "sfml-main.lib" in Release), the same way you linked sfml-graphics, sfml-window and sfml-system."
Last edited on
Thanks for the efforts to say what steps to take but it is all very messy and unclear. I uninstalled Code::Blocks and the SMFL folder and started all over again. I wasn't sure if I had to install Code::Blocks in C:/Programs Files/ or if I could just install it in C:/ as I did with the SFML sdk.

The real problem is that saying do x,y and z without actually saying how to do x,y and z leaves me floating. You mention Debug and Release and say the same way I linked sfml-graphics. Well all I did was follow the instructions without understanding the reason why and I don't remember any mention of Debug or Release. The other thing is when I started a new project all the stuff I had to type in via the Project>Build options has vanished. The instructions said I only had to do it once??

I started up Code::Blocks and chose an empty project that I called graphic1 and followed the instructions which were to,
Add a "main.cpp" file to your project,
which I did by File > New > File ... >
and selecting a C/C++ source File icon calling it main.cpp as instructed and pasting in the given source code.


Then I tried to build/run it and keep getting a message box,
"It seems this that this project has not been built yet."
"Do you want to build it now?"

Selecting [yes] just keeps popping up the same message box.

The error output is:

-------------- Build: Debug in graphics1 (compiler: GNU GCC Compiler)---------------

Linking stage skipped (build target has no object files to link)
Nothing to be done (all items are up-to-date).


-------------- Run: Debug in graphics1 (compiler: GNU GCC Compiler)---------------

Checking for existence: C:\SFML-2.3.2\examples\graphics1\bin\Debug\graphics1.exe

No idea what to do with that information.

Now I know other self taught programmers have had the same nightmare. I have no access to a teacher or anyone who can step me through it on my own computer. Is it really that hard to automate the process as is done with the more advanced languages? I would use DevPak but they say it is unsafe.

Last edited on
@ TheHardew: What TheIdeasMan RUNNER_PRO_AGARIO meant to point out is that Code::Blocks comes packaged with MinGW so OP would have to link to libsfml-main.a which is the version of the library made for GCC compilers. Although it is perfectly valid for Code::Blocks to use cl, it's exactly what I do after all, it's not likely for a beginner to make that kind of change on their own.

OP wrote:
Well all I did was follow the instructions without understanding the reason why...

Not for nothing OP, but this is the crux of your problem right here. I didn't say to make sure those dll files are in your bin folder, did I? I said to put them in your project folder. There is a noteable difference: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx#search_order_for_desktop_applications

Linking stage skipped (build target has no object files to link)
Nothing to be done (all items are up-to-date).


By the way, this error means that you probably didn't add your source file to your project.

EDIT: Fixed.
Last edited on
Hi Computergeek01 :+)

Just wondering what it was that I said, I was not part of this topic - maybe something was edited out of TheHardew's post ?

Cheers :+)
CodeWriter wrote:


Linking stage skipped (build target has no object files to link)
Nothing to be done (all items are up-to-date).


Computergeek01 wrote:
By the way, this error means that you probably didn't add your source file to your project.

CodeWriter reply:

Then I don't know how to "add a source code". There is a file added isn't that a source file?

The problem appears to be not having enough knowledge of how the compiler deals with all this stuff.

My current C++ book using Code::Blocks simply says select the Console Application icon and that works fine. There is no instructions on empty files etc. What is needed is an icon for SFML applications that actually works. I have found a Code::Blocks forum so maybe that is where I should direct my problems.

I did try using the SFML icon but it seems only to handle versions SFML 1.6 and SFML 2.0
When I tried to use SFML 2.0 icon the example failed to compile. Maybe I need to use an older version of SFML.

============================
Well I just downloaded the SFML 2.0
It had a different set of items,
sfml-graphics-s-d
sfml-window-s-d
sfml-system-s-d
sfml-main-d
Which wouldn't compile so I changed them to,
sfml-graphics
sfml-window
sfml-system
sfml-main
The program did compile and ran but it gave a console screen with a pop up error window,
"The procedure entry point_gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll"
Which was of no help as it didn't say what to do about it which is the problem with all these error messages.
I had chosen SFML_STATIC so it makes no sense to me.
Last edited on
Yeah, why was TheIdeasMan referenced, do you see similarities in us or something?
Yeah, why was TheIdeasMan referenced, do you see similarities in us or something?


I'll let that one go through to the Keeper :+)
Lol, ok ; -)
Computergeek01 wrote:
"Compiling SFML yourself would be best..."

Ok I checked that out, the smfl tutorial did make such a suggestion:

"If you feel like your version of gcc can't work with the precompiled SFML libraries, don't hesitate to build SFML yourself, it's not complicated."

Well looking at the steps involved it is complicated. The instructions assume you have knowledge which a self taught programmer may not have. It says do x,y and z assuming you know how to do x,y and z. Anything is easy when you know how to do it.

Essentially I now understand the problem to be matching the binaries (which I haven't been able to figure out how to make myself) with the compiler being used. Why can't the SMFL team just provide the binaries and be done with it once and for all. I have no problem with console C++ programs or with other languages that simply import libraries as required.

.
Building SFML or any library can be difficult until you've done it a few times.
Have you looked at the tutorial for building with cmake? http://www.sfml-dev.org/tutorials/2.2/compile-with-cmake.php
Looks like they explain it well.
@naraku9333,

Yes I downloaded and unzipped the CMake but couldn't find any .exe file for the cmake-gui
.
Most of the files are .rst files whatever that means.
.
Which package did you download? If you downloaded the binary distribution zip file there is a bin directory with the binaries in it.
raraku9333,
Thanks. I downloaded the incorrect file,
cmake-3.5.0-rc1.zip
I have just downloaded this file and it contains the cmake-gui.exe
cmake-3.5.0-rc1-win32-x86.zip
When I get time I will try again.
.
Topic archived. No new replies allowed.