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.
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'
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.
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:
#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?
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.