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

Author Topic: SFML visual studio error  (Read 1488 times)

0 Members and 1 Guest are viewing this topic.

gigi

  • Newbie
  • *
  • Posts: 3
    • View Profile
SFML visual studio error
« on: August 05, 2016, 12:52:19 am »
Hi, I followed the guide for configuring sfml with visual studio 14 but when I run the example code at the end of the guide, VS say that there were build errors and even when I write a main function with nothing inside except return 0, an error appear:

1>MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>c:\users\karim\documents\visual studio 2015\Projects\ConsoleApplication2\Debug\ConsoleApplication2.exe : fatal error LNK1120: 1 unresolved externals

I did exactly what was written in the guide except when linking the application to the SFML libraries I put ; instead of spaces to separate each sfml-xxx.lib (There are less errors  when I put  ; instead of spaces) and also I skipped the part for linking to the static version of SFML and theres a part that talks about dependencies of each SFML modules and I didn't know what to do with that finally there is this written in the guide:
"If you chose to create a "Windows application" project, the entry point of your code has to be set to "WinMain" instead of "main""
I also didn't know what to do with that so I just added a c++ file in the source files folder and tried to call it WinMain and Main but it still didn't work. (main lowercase m didn't work because there is already a "main" file but somehow VS doesn't show it in my project and I can't access it)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML visual studio error
« Reply #1 on: August 05, 2016, 01:30:30 am »
I suggest to start with an "Empty project" instead of a "Windows application". Then you can use int main() and make sure to only link sfml-main in release mode, plus only switching the subsystem in release mode to window.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

gigi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: SFML visual studio error
« Reply #2 on: August 05, 2016, 02:57:21 am »
it doesn't work :(

gigi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: SFML visual studio error
« Reply #3 on: August 05, 2016, 03:40:59 am »
I followed a video on youtube and now it works!