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

Author Topic: Trouble with Visual Studio 2012, main()?  (Read 3817 times)

0 Members and 2 Guests are viewing this topic.

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Trouble with Visual Studio 2012, main()?
« on: January 03, 2014, 12:10:20 am »
Is there a special entry function that I have to use for a win32 app? I am following the tutorial for vs and I made a win32 application i believe and It gives me an error when I don't even have any special code just the int main() and the return 0; inside that. Do I have to use a special entry function? And why? I tried searching for it but I don't think I really saw an answer. Thanks for your help!

Daddi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://foxdev.de/
    • Email
Re: Trouble with Visual Studio 2012, main()?
« Reply #1 on: January 03, 2014, 12:32:02 am »
Well, if you create an empty VS 2012 project you get the following:

int _tmain(int argc, _TCHAR* argv[])
{
        return 0;
}
 

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Trouble with Visual Studio 2012, main()?
« Reply #2 on: January 03, 2014, 12:48:42 am »
I made a win32 application I'm pretty sure, so what should I use then?

Daddi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://foxdev.de/
    • Email
Re: Trouble with Visual Studio 2012, main()?
« Reply #3 on: January 03, 2014, 12:51:18 am »
Whats the error you get? Have you changed the project properties already?

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Trouble with Visual Studio 2012, main()?
« Reply #4 on: January 03, 2014, 12:54:21 am »
No I havent setup the program with SFML, this is the error:

Error   2       error LNK1120: 1 unresolved externals   D:\Coding and Animation\Workspace\Projects\Voxel Delivery Service\Debug\Voxel Delivery Service.exe      1       1       Voxel Delivery Service
Error   1       error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup D:\Coding and Animation\Workspace\Projects\Voxel Delivery Service\Voxel Delivery Service\MSVCRTD.lib(crtexew.obj)       Voxel Delivery Service

 

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Trouble with Visual Studio 2012, main()?
« Reply #5 on: January 03, 2014, 12:55:39 am »
Maybe it would be easier to ask if this is possible. Can I make an SFML project with an Empty Project? O r will that make the program appear with a console?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Trouble with Visual Studio 2012, main()?
« Reply #6 on: January 03, 2014, 12:57:20 am »
Well, if you create an empty VS 2012 project you get the following:

int _tmain(int argc, _TCHAR* argv[])
{
        return 0;
}
 
That is not at all an empty project. _tmain is some Windows specific stuff. You should really start of with a empty project, so VS doesn't get the chance to add some ugly code.

You can then simply go with:
int main()
{
    return 0; // Can also be omitted in the main function and is valid by the standard
}

SFML provides the sfml-main.lib for Windows. If you're in debug mode, I suggest to keep the subsystem set to console, because you'll be able to output important debug information on the console window - don't link against sfml-main.lib if you use the subsystem console.
In release mode, you can set the subsystem to Window and link against sfml-main.lib and everything should work fine.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Daddi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://foxdev.de/
    • Email
Re: Trouble with Visual Studio 2012, main()?
« Reply #7 on: January 03, 2014, 01:00:31 am »
I didn't mean an empty project but the VS "Empty Project" Template, which starts with a simple _tmain like above. I don't use VS myself but I thought _tmain may be required in their compiler, hence the code example ;)

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Trouble with Visual Studio 2012, main()?
« Reply #8 on: January 03, 2014, 01:11:26 am »
If I used code::blocks instead of vs, would I have to worry about all this Windows stuff that keeps confusing me? I do not need to use winAPI, I just want to use SFML for drawing stuff and later on a 3d library. Will code::blocks be better if I don't want to be bothered with the whole, linking with sfml-main and changing the output thing (Windows, console?). I am starting to not like vs anymore because of its complexity.

Or is there a way that I can start just a simple project in vs, with no code in it, and that I can just setup sfml and use int main()?
« Last Edit: January 03, 2014, 01:15:06 am by nicedude80 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Trouble with Visual Studio 2012, main()?
« Reply #9 on: January 03, 2014, 01:22:17 am »
Code::Blocks is just something different, but there's still a lot of stuff that can confuse you, starting by the choice of compiler and matching SFML binaries. ;)

Programming is a hard thing, there's no easy way out, so better settle in and accept that you'll have to deal with a lot of issues all the time. Over time you'll get better and better at solving such issues, but until then it's a bit unpleasant. ;)

As I've already said: Create an "Empty Project" - not an Win32 and not a Console application, but an Empty Project.
From there you can add your source file and start with a clean plate.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Trouble with Visual Studio 2012, main()?
« Reply #10 on: January 03, 2014, 01:29:34 am »
Ok thanks! So I will still have to add sfml-main-d.lib (and sfml-main.lib for release) with all the rest of the libraries (sfml-graphics-d.lib etc) to be able to get rid of that console, but still be able to use int main()? So then I would just use int main() and it wouldn't open any console? Or does an empty project automatically not give you a console and allows you to still use int main()? Jeeze this is confusing :(

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Trouble with Visual Studio 2012, main()?
« Reply #11 on: January 03, 2014, 01:50:27 am »
Also, I found that there is no sfml-main(-d).dll file? Does that mean I have to link statically if I want to use sfml-main(-d).lib?

Sorry for all the questions and thank you all for your help!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Trouble with Visual Studio 2012, main()?
« Reply #12 on: January 03, 2014, 01:53:13 am »
By default the subsystem is set to console, thus you'll end up with a console.
I suggest to keep the console for debug mode and get rid of it in release.

If you don't want the console, you'll need to change the subsystem setting to Window and link against sfml-main(-d).lib

There's no dll file, because it doesn't make sense to link that one library dynamically, but you don't need to worry about that and you don't need to defined SFML_STATIC or anything. Just link it, even if the other libraries are dynamic. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nicedude80

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Trouble with Visual Studio 2012, main()?
« Reply #13 on: January 03, 2014, 01:55:48 am »
Ok thanks! Now, is there any good to use 3D engines/libraries that are easy to use? I am assuming not lol

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Trouble with Visual Studio 2012, main()?
« Reply #14 on: January 03, 2014, 02:28:57 pm »
Now, is there any good to use 3D engines/libraries that are easy to use?
You could have a look at Irrlicht, it's quite beginner-friendly.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything