This is a quick post to show how to use the sfml library within our beloved QTCreator. The sfml library is a very clean, cross-platform and easy to use library for windowing, opengl, networking, audio and more. Check it out it’s really good.
It turns out it’s really easy to start playing with sfml, which one of the reasons why everyone loves it.
- First download the appropriate version from here (I downloaded the Windows – MinGW code::blocks version which works perfectly with the QTCreator/MinGW compiler)
- Extract the file archive to a directory, for example the C:\SFML
- Make sure that the directory you extract it to has no spaces in it, as that could be a problem with QTCreator.
- Copy dlls from the SFML\lib directory to C:\Windows\system32 directory for the 32-bit version of Windows or to the C:\Windows\SYSWOW64 director for the 64-bit version of Windows. You could also just copy the dlls to your executable directory.
- You don’t have to copy all the dlls, but just the ones you need. For example if you just use the system library, you could just copy the sfml-system.dll for the release version and/or the sfml-system-d.dll for the debug version.
- Finally, you just have to add the paths to the project file as so:
INCLUDEPATH += C:\SFML\include LIBS += C:\SFML\lib\libsfml-system.a \ C:\SFML\lib\libsfml-window.a \ C:\SFML\lib\libsfml-graphics.a \ C:\SFML\lib\libsfml-audio.a \ C:\SFML\lib\libsfml-network.a
That’s it. Now download sfml and get creating 🙂