Enabling SFML under Visual C++ 2010

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 ;)

Setting up...

Well that was interesting. Let's sum up how miserable I was in the course of the last two days, and hope it can help some people not be as miserable (or laugh at me, who knows).

  • Finding a way of accessing my OVH hosting though SSH: not as easy as it seems in their guide. They say one can indifferently connect to pro.ovh.net or to one's own domain? Well I didn't, ever, managed to log in pro.ovh.net. Had to use my domain name.
  • Setting up wordpress: no problem, nice and easy. Uploading some files through Filezilla (since OVH won't let users access the internet from SSH), creating a database, launching a script. Not too hard.
  • Setting up SVN: the OVH guide about that one is correct, at least. So you can follow it (french): http://guides.ovh.com/SVNMutu. A good thing to know: if (like me) you are some kind of barbarian and use Putty's exe file instead of installing it, "loading the key into Pageant" is not as simple as a double click, don't forget to map the "Putty key file" file extension to Pageant first. And, at least under Windows 7, the "icon in the lower right corner" does not appear, except in the notification area.
  • Setting up websvn: no problem either. Again, uploading, unzipping, setting the svn root directory in the config.php file (which doesn't exist! You have to copy include/distconfig.php to create it).
  • Adding authentication to websvn: now that was fun. Took me three hours. Every tutorial I stumbled upon used some Apache-specific features, which I apparently didn't have on my hosting. I finally quitted the idea of doing something clean, and made a very simple .htacess in the websvn root directory (four lines: AuthName, AuthType, AuthUserFile, Require valid-user) and a .htpasswd (which isn't in the accessible web directories of course ;)). The drawback is I can't filter acess by repository with this technique: but heck, it's better than having everyone viewing my SVN repositories.
  • Finding out WebSVN has messed up with PHP version and broken WordPress and fixing it, i.e. adding SetEnv PHP_VER 5 at the beginning of WordPress' .htaccess.

Next step is integrating a bug tracker (I'm thinking of Mantis). We'll see how it goes, I have all the time in the world.