SFML library

Hello!

I've just downloaded the SFML library for Windows (which is made for Code::Blocks). The problem is very simple: it doesn't work when I try to install it. I read the tutorial on this site: http://www.sfml-dev.org/tutorials/1.6/start-cb.php but it simply doesn't work. First of all, I've copied all that files from the library folder of SFML in 'library' folder from Code::Blocks. And the same thing for headers. It doesn't work. When I try to compile the example it gaves me 4 errors. On the other hand, I went (in C::B) Settings ->Compiler and Debugger -> Search directories -> in the Compiler tab I've added "C:\SFML-1.6\include" and in the linker tab I've added "C:\SFML-1.6\lib". When I run the example it gaves me the same errors. Please help me. Thanks.
What are the errors?
The errors are:

undefined reference to 'sf::Clock::Clock()'
undefined reference to 'sf::Clock.GetElapsedTime() const'
undefined reference to 'sf::Sleep(float)'
undefined reference to 'sf::Clock.GetElapsedTime() const'

Have you linked -lsfml-system?
(go to project build options > linker settings > other linker options > write "-lsfml-system", whithout quotes)
I've linked now -lsfml-system and it compiles without any errors. But it doesn't run either. When I want to run it, appears an error: "This application has failed to start because sfml-system.dll was not found. Re-installing the application may fix this problem." I've copied that file in the executable's folder (in the Debug folder) and now it gaves me ANOTHER error: "This application...because libgcc_s_dw2-1.dll was not found. Re-installing...this problem". Now I don't know where is this file.
Last edited on
You should try looking on youtube to see if they have anything on setting up SFML in Code::Blocks. They have plenty of tuts on that.

Here's a link:

http://www.youtube.com/watch?v=sgLqziVwey4

I've watched the tutorial. It makes all the things I made. But he simply doesn't get that error. What shall I do? Can anyone help me?
O.O Oh My. Are you including the necessary files in your project's directory location!?
I finaly figured it out. I found that file and I put it in Debug folder. Now it works. Thanks for help. I don't want to be nasty but I have one last problem.
I tried to run this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <SFML/Audio.hpp>
 #include <SFML/Graphics.hpp>

 int main()
 {
     // Create the main window
     sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");

     // Load a sprite to display
 /*    sf::Image Image;
     if (!Image.LoadFromFile("cute_image.jpg"))
         return EXIT_FAILURE;
     sf::Sprite Sprite(Image);


     // Load a music to play*/
     sf::Music Music;
     if (!Music.OpenFromFile("nice_music.ogg"))
         return EXIT_FAILURE;

//     Play the music
     Music.Play();

     // Start the game loop*/
     while (App.IsOpened())
     {
         // Process events
         sf::Event Event;
         while (App.GetEvent(Event))
         {
             // Close window : exit
             if (Event.Type == sf::Event::Closed)
                 App.Close();
         }

         // Clear screen
         App.Clear();

//           Draw the sprite
        /*App.Draw(Sprite);

         // Draw the string
        // App.Draw(Text);

         // Update the window*/
         App.Display();
     }

     return EXIT_SUCCESS;
 }
. Is an example. I want to play that music. I converted a file from mp3 to ogg and I've put it in Debug folder with the name "nice_music.ogg". When I run it, says: "Failed to open "nice_music.ogg" for reading. What is the mistake?

Thanks respectfully.
Hoho.

I remember the time when I had trouble with music files. Problem is:

Do you actually have the file nice_music.ogg in the same place as your projects directory location. If not, it'll fail every time. If you want to use a custom sound, or soundtrack... you may want to find a converter that converts mp3's to ogg's.

Same thing for everything you ever use in SFML. If you load a stick man as a player sprite, you must have the image in your project's directory location. Always. Make that a cardinal rule, and you'll be fine.
But I've already told you that. I said that "I've put it in Debug folder" and that means: In the folder Debug is the executable, a few dll-s and that ogg file, called "nice_music.ogg". So, ogg file is near the executable (and it still give me that error: Failed to open....) Where do I have to put it? Near the main.cpp?. Yours respectfully.
Last edited on
Next to main.cpp
Allright! It works! Thanks a lot to everybody!
Topic archived. No new replies allowed.