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

Author Topic: Trouble building SFML 2.0 snapshot with VS 2010 Pro(Fixed)  (Read 4227 times)

0 Members and 2 Guests are viewing this topic.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Trouble building SFML 2.0 snapshot with VS 2010 Pro(Fixed)
« on: June 06, 2012, 05:16:09 am »
Hello.  I am having trouble building the SFML 2.0 snapshot located on the download page.  I am trying to build it because I use Visual Studios 2010 Proffessional and there isn't already a package available for it.  I had been doing some research into graphics libs on youtube hoping to find something I liked and settled on trying SFML.  I found 2 videos there for building SFML with VS 2010 Express and gave them a try.

The first video, , uses cmake-gui to create a solution file that can be loaded into VS 2010.  Once made, you load the solution and create release/debug libraries then the author shows how to set up properties so that a project can compile using the new libraries.  After doing this I came across a problem in the linking phase of compilation(To be explained after I go over my attempts to resolve my issues).

The second video, http://www.youtube.com/watch?annotation_id=annotation_175195&src_vid=cDNo4bzrFW8&v=PtSDrLpV74M&feature=iv, uses cmake and nmake to create the libraries.  Again, after completing the steps in the video and trying a sample program I had problems.

Next I looked over the SFML site and found the tutorial on building SFML there(http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php) and followed it.  Then I went to the page(http://www.sfml-dev.org/tutorials/2.0/start-vc.php) detailing how to set up VS 2010 so that it can find the libraries and compile with them.  I again had problems after compilation and during the linking phase.  On the VS 2010 setup page a mention is made of using SFML_STATIC in the C/C++ preprossor when using static library builds.  I tried compilation with and without that setting while using the correct nomenclature of '-s' and '-s-d' on static builds and whatnot.

I have gone through many attempts at compilation of the sample program listed on the VS 2010 setup page using various settings for the project with no luck.  At best what it boils down to for me is this error:

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

So, out of frustration I downloaded Code::Blocks and used my own install of MinGW from their website so that I was sure to have the most current version of the MinGW compiler system.  I went back to the page detailing how to create the libraries using CMake, made a make file for MinGW-make, and built the libraries.  I followed the instructions on this page(http://www.sfml-dev.org/tutorials/2.0/start-cb.php) to set up Code::Blocks and then compiles the example program at the bottom of the page.  It worked.  I had to copy the DLL files to my EXE file directory, but that was expected(and I didn't know how to go about making the static libs).

As you can see, I've tried many options to get SFML to compile under VS 2010 correctly, but I just can't get it to work.  I hear good things about Code::Blocks, but I'd rather use VS 2010(I bought the damn thing after all).  Any help would be appreciated.  If needed I can go through my setup processes again and get exact errors on the builds and post them here for further information.

**Sorry for the video link.  I've never made a post to a board that did things this way and I'm not sure why the second link didn't also create a video in this post.

EDIT - Forgot to mention I also tried compiling the current SVN files by converting the VS 2008 solution to VS 2010.  Again that failed me.
« Last Edit: June 06, 2012, 09:37:06 am by Spirro »

Blader

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Trouble building SFML 2.0 snapshot with VS 2010 Pro
« Reply #1 on: June 06, 2012, 06:36:51 am »
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

Have you tried solutions from googling this error ID?

Here are some potential solutions:

1. Please change the "subsystem" in your linker settings from "Windows" to "Console".
2. In the Output category of the Link tab in the Project Settings dialog box, set the Entry Point Symbol to wWinMainCRTStartup.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Trouble building SFML 2.0 snapshot with VS 2010 Pro
« Reply #2 on: June 06, 2012, 08:12:58 am »
First, SFML 2.0 RC is available for VS 2010 in precompiled form on the download page. You don't need to compile it.

Second, the "Getting started" tutorial says everything that you need to know, and has the solution to your problem. Just read it carefully, follow the steps, and everything will be ok.
Laurent Gomila - SFML developer

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Trouble building SFML 2.0 snapshot with VS 2010 Pro
« Reply #3 on: June 06, 2012, 08:48:01 am »

Have you tried solutions from googling this error ID?

Here are some potential solutions:

1. Please change the "subsystem" in your linker settings from "Windows" to "Console".
2. In the Output category of the Link tab in the Project Settings dialog box, set the Entry Point Symbol to wWinMainCRTStartup.

Ok.  I spent some time testing your solution options.  I changed my subsystem to console.  This allowed me to compile both debug and release versions of the test file, but openned a console window.  That's something I didn't want to do.

I then changed the entry point with both subsystem settings to no effect.  The test file wouldn't compile.

When trying to figure out this problem I did all my searches here on the forum before posting.  After trying your answers I did then hit google and after a while found a very old post that mentioned setting the entry point to 'main'.  I made a new project and set up everything as per the vs 2010 tutorial page to be sure I had everything correct.  Then I set the entry point to 'main' and I got the test program compiled properly and it ran without a console window so thank you very much for the entry point suggestion.

First, SFML 2.0 RC is available for VS 2010 in precompiled form on the download page. You don't need to compile it.

Second, the "Getting started" tutorial says everything that you need to know, and has the solution to your problem. Just read it carefully, follow the steps, and everything will be ok.

You're right here on the first point.  As I mentioned above I was looking on youtube for graphics examples of libraries so when it came down to me compiling the source for SFML I did NOT scroll down any further to see that the libraries had actually already been compiled for everyone.  That's what I get for just watching a video.

For your second point I must just be missing something.  I assume you are talking about the cmake tutorial under getting started.  I've gone through that step several times to no avail.

I did download the compiled libraries and got them to compile the test program successfully, however I did still need to change my entry point to 'main'.

Thank you both.  Issue solved.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Trouble building SFML 2.0 snapshot with VS 2010 Pro
« Reply #4 on: June 06, 2012, 09:07:00 am »
Quote
For your second point I must just be missing something.  I assume you are talking about the cmake tutorial under getting started.
No no, CMake is for compiling SFML, and I said you don't need it. I was talking about the "SFML and Visual Studio" tutorial, and specifically this paragraph:
Quote
If you chose to create a "Windows application" project, then the entry point of your code has to be the "WinMain" function instead of "main". Since it's Windows specific, and your code would therefore not compile on Linux or Mac OS X, SFML provides a way to keep a standard "main" entry point in this case: link your project to the sfml-main module ("sfml-main-d.lib" in Debug, "sfml-main.lib" in Release), the same way you linked sfml-graphics, sfml-window and sfml-system.
Laurent Gomila - SFML developer

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Trouble building SFML 2.0 snapshot with VS 2010 Pro(Fixed)
« Reply #5 on: June 06, 2012, 09:55:45 am »

No no, CMake is for compiling SFML, and I said you don't need it. I was talking about the "SFML and Visual Studio" tutorial, and specifically this paragraph:
Quote
If you chose to create a "Windows application" project, then the entry point of your code has to be the "WinMain" function instead of "main". Since it's Windows specific, and your code would therefore not compile on Linux or Mac OS X, SFML provides a way to keep a standard "main" entry point in this case: link your project to the sfml-main module ("sfml-main-d.lib" in Debug, "sfml-main.lib" in Release), the same way you linked sfml-graphics, sfml-window and sfml-system.

Another fault on my part.  I added sfml-main.lib to linker/input/additional dependencies as my first listing for release and sfml-main-d.lib as my first listing for debug.  This does compile correctly without having to change my entry point to 'main'.

Thank you very much Laurent.

 

anything