Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML on Visual Studio 2012  (Read 5848 times)

0 Members and 1 Guest are viewing this topic.

powf

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML on Visual Studio 2012
« on: November 28, 2012, 02:46:34 am »
I had a long post written up, but then my computer crashed. So I'll be (relatively) concise; I'm trying to build the SFML library so I can include it in a VS2012 project:

1. I built SFML using CMake. However, when I tried "Nmake makefiles" (as my 'generator') it gave me an error. So then I tried 'Visual Studio 2011" (it has no 2012?) and it configured/generated successfully. Is this right?

2. I opened SFML.sln and built it (my only previous experience with building was with simple .exe files). It seems that a few .dll files were generated. If I did step 1 correctly, which files should I include? My lib folder (looking in the same directory as the .sln file is in) is empty with the exception of a Debug folder with many files in it and an 'include' folder doesn't even exist in the directory.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML on Visual Studio 2012
« Reply #1 on: November 28, 2012, 03:06:17 am »
It should be correct but there's no such thing as visual studio 2011 (unless I'm missing something), visual studio 11 however is visual studio 2012.
Both visual studios and vc++ use both numbers and years at times, to make it even better, it's often mixed: run visual 2010 professional installer, get fresh great setup in folder called.. Microsoft Visual Studio 10.0
Vs 2010 is vs 10 and comes with vc++ 10(happy coincidence). Vs/c++ 2008 is 9 and 2012 is 11.
Quote
2. I opened SFML.sln and built it (my only previous experience with building was with simple .exe files). It seems that a few .dll files were generated. If I did step 1 correctly, which files should I include? My lib folder (looking in the same directory as the .sln file is in) is empty with the exception of a Debug folder with many files in it and an 'include' folder doesn't even exist in the directory.
If you ran everything ok you should have sfml installed somewhere nicely and there will be include folder that you must add to additional include directories and lib folder that you must add to additional linker folders, then link against sfml-MODULE_NAME_HERE.lib with optional trailing -d for debug and -s for static, also if doing static there is macro you need to define and if using dynamic ones place .dlls(that can be found in install folder in /bin) around the .sln .vcprojx(when ran from ide) or .exe(when ran from exe). Tutorials explain everything nicely.
« Last Edit: November 28, 2012, 03:10:53 am by FRex »
Back to C++ gamedev with SFML in May 2023

powf

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML on Visual Studio 2012
« Reply #2 on: November 28, 2012, 07:14:44 am »
Ok, I think I've figured out my problem with the 'include' folder. It was in the file I downloaded instead of the one CMake made. It seems to have all the .h files I need inside it. Before trying this out, though, there's something else that bothers me. In the 'library' folder, all the built .dll and .lib files are debug, nonstatic files. What is the effect of having the debug tag? In CMake, the CMAKE_BUILD_TYPE is 'Release', not 'Debug'. If it's recommended to remove the debug tag at some point (maybe in the finished application?), what do I need to do?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML on Visual Studio 2012
« Reply #3 on: November 28, 2012, 07:49:47 am »
Quote
Both visual studios and vc++ use both numbers and years at times, to make it even better, it's often mixed
Wrong: VC++ uses incremental numbers and Visual Studio uses years ;)

Quote
In the 'library' folder, all the built .dll and .lib files are debug, nonstatic files. What is the effect of having the debug tag? In CMake, the CMAKE_BUILD_TYPE is 'Release', not 'Debug'.
How did you build, with Visual Studio or with nmake? If you build with Visual Studio, CMAKE_BUILD_TYPE is ignored because the generated solution can handle both Release and Debug; it's up to you to choose the right configuration in the IDE before building.
Laurent Gomila - SFML developer

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML on Visual Studio 2012
« Reply #4 on: November 28, 2012, 05:50:53 pm »
Quote
Wrong: VC++ uses incremental numbers and Visual Studio uses years ;)
I admit that vc++ _year_ is rarest combo out of the four(just the wiki and redistributable is called 'visual c++ redistributable _year_' to run on machines without 'visual c++ _year_' installed) and visual studio usually uses years, but in cmake and in default install path that is set in vs2010 installation software made by microsoft it installs into ../Microsoft Visual Studio 10.0/.. So all four are microsoft 'somewhat approved' naming conventions.
(..ahem..Hungarian Notation.. *cough*)
Ah.. confusions.. to make it even better lots of people use visual c++ and visual studio interchangeably too.  ;D
« Last Edit: November 28, 2012, 06:01:20 pm by FRex »
Back to C++ gamedev with SFML in May 2023

powf

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML on Visual Studio 2012
« Reply #5 on: November 29, 2012, 01:03:50 am »
As you said, I built straight from VS2012, not from nmake; I guess that explains why I'm getting debug files. After doing a bit of poking around, I managed to find a way to get all the files into 'release' mode. Are the files shown here (http://i.imgur.com/jnRKk.png) all that I need besides the .h files? It looks as if switching from debug to release building removed some files with extensions .pdb and .ilk (present in the debug build).
« Last Edit: November 29, 2012, 04:29:37 am by powf »

fallout

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: SFML on Visual Studio 2012
« Reply #6 on: November 29, 2012, 06:54:18 am »
Edit: got things working. Had the wrong dll files with exploiter's recent build.
« Last Edit: November 29, 2012, 07:33:16 am by fallout »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Re: SFML on Visual Studio 2012
« Reply #7 on: November 29, 2012, 08:47:01 am »
It looks as if switching from debug to release building removed some files with extensions .pdb and .ilk (present in the debug build).
The pdb file contains debug symbols which you obviously don't need in release.

As for your problem, simply set an install dir in CMake and then select the INSTALL project in VS and only build that. Then you can switch to release/debug and build it again and everything that's need gets magically copied to the install dir.

(Or use my nightly builds)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

powf

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML on Visual Studio 2012
« Reply #8 on: November 30, 2012, 02:40:04 am »
Thanks for that - now that I know what to use, it was a quick task to get things set up and working. One thing, though - when I'm using the release files and building the project (the compiled program at the bottom of http://www.sfml-dev.org/tutorials/2.0/start-vc.php) in debug mode, it comes up with 3 gibberish characters in the top left hand corner instead of "SFML works!". But if I build and run it in release mode, it behaves normally. Either way, it doesn't seem like a big problem - it still draws the circle either way; I just hope that it's not a sign of worse things to come. Thanks, guys!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML on Visual Studio 2012
« Reply #9 on: November 30, 2012, 07:57:36 am »
It's clearly written in the tutorial: you can't use release libraries in debug mode. They are not compatible.
Laurent Gomila - SFML developer