I'm writing this because (at least for now) the SFML is "only" available for Visual Studio 2005 and 2008, plus MinGW. Yes I could use free software, but the whole point being to get familiar with Visual Studio, that would be a shame. So, SFML and Visual Studio.
First things first: in order to avoid compatibility issues, you have to recompile the SFML (or download my binaries if you're lazy :D). Follow these steps:
- Download the full SDK at this address: http://www.sfml-dev.org/download.php.
- Extract it in a directory which will be the permanent location of the library.
- Open SFML.sln, located in build/vc2008.
- Visual Studio will offer to convert the project. Click "Next" until it's done. There will be a few errors: it's not a big deal, they're in the examples.
- Remove all projects with do not begin with "sfml-" from the solution.
- Then build the four targets: Debug DLL, Debug static, Release DLL, Release static (pick from the drop down on the upper left).
- Everything should build fine: close the solution.
- The build created lib files in lib/vc2008: I replaced the ones at the root of lib with these new ones.
In order to link the SFML to a project, two steps are required. First, Visual requires the library's location. Go into the project's properties, Configuration Properties, VC++ Directories. In the drop-down menu on the upper left, pick All Targets, and:
- In Include Directories, add the include directory from the SFML location.
- In Library Directories, add the lib directory from the SFML location.
The second step is to tell the linker which libraries to use. Go into Configuration Properties once more, Linker, Input. Then:
- For Debug configuration: indicate the libraries you use, looking like sfml-...-d.lib
- For Release configuration: indicate the libraries you use, looking like sfml-....lib
- If you want to link statically (embedding in executable) instead of dynamically (DLLs), you must use sfml-...-s-d.lib and sfml-...-s.lib.
If you're using dynamic linking, you'll have to copy the required DLLs (both debug and release versions) in the project's directory (not the solution's).
And if I haven't forgotten anything, your project should build and run just fine. Visual will protest about missing PDB files in Debug configuration, but it's not an issue. At first, I forgot to replace the files in lib with the ones in lib/vc2008 and the program worked in Release but not in Debug mode ("Application failed to start correctly, error 0xc0150002" or something like that).
With all this in place, and using the tutorials here, I quickly obtained a window with the infamous spinning cube. I'm now building a small terrain generation demo, but the details will have to wait a little ;)