In this video I show you how to make a first project file in Visual Studio or Visual C++ Express which uses SFML 2.0.
The main focus of the lesson is setting up the search directories for the compiler and linker, and linking the actual SFML 2.0 libraries:
sfml-graphics[-s][-d].lib
sfml-audio[-s][-d].lib
sfml-window[-s][-d].lib
sfml-system[-s][-d].lib
sfml-network[-s][-d].lib
where the optional -s is for static and the optional -d is for debug.
Note that when linking with the static libraries, one must define the global compiler macro SFML_STATIC.
Note also that when linking dynamically, one must put the corresponding dynamic libraries in the project directory:
sfml-graphics[-d]-2.dll
sfml-audio[-d]-2.dll
sfml-window[-d]-2.dll
sfml-system[-d]-2.dll
sfml-network[-d]-2.dll
Be aware that (of course!) you need not link static/import libraries or provide dynamic libraries corresponding to modules your are not using.
We compile some test code which you may find here: http://ideone.com/PXw13
Finally, we see how to prevent our SFML application having a console window as well as the GUI window, and we consider additional DLLs needed by SFML.
Notes:
(Thanks for tr1kker for pointing this out)
You must link the C runtime to your library in the same way it was linked to the SFML binaries. I have run out of space in this area, so see the comments section for details on how to change the C runtime used by your project.
Relevant links:
SFML: http://sfml-dev.org
Visual C++ Express: http://www.microsoft.com/express/Downloads/#2010-Visual-CPP
SFML Coder: http://sfmlcoder.wordpress.com/
See also:
Textual 'Building SFML 2.0' Tutorial:
http://sfmlcoder.wordpress.com/2011/05/11/building-sfml-2-0/
Textual 'First Project' Tutorial:
http://sfmlcoder.wordpress.com/2011/05/18/creating-a-first-sfml-project/
Building SFML 2.0 in Visual Studio:
http://www.youtube.com/watch?v=fMNlUfvWOwA
Hi, I did everything you've said to do. I got all the Binaries for SFML2. set the linker and all that as you described in your video and i get this:
error C2039: 'IsOpened' : is not a member of 'sf::RenderWindow'
VERY good tutorial by the way.
FacePalmCPP 1 week ago
@FacePalmCPP Yes. IsOpened() has been renamed IsOpen(). I'll update the video eventually, I just haven't had the chance yet...
And thanks!
SFMLCoder 1 week ago
i put the dll´s in the debug folder of my project. now it works.
kaleight1 5 months ago
@kaleight1 Great. I'm pretty sure it should also work to put them in the main project directory, provided you are running the program from within the IDE.
SFMLCoder 5 months ago
@SFMLCoder yes that works too
kaleight1 5 months ago
@kaleight1 Good. Is that not what the video says? If not, I'd better add a note in the video information section, at least until I have to chance to update the video itself.
SFMLCoder 5 months ago