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

Author Topic: Cant compile sfml on windows  (Read 2529 times)

0 Members and 1 Guest are viewing this topic.

d4nn97

  • Newbie
  • *
  • Posts: 6
    • View Profile
Cant compile sfml on windows
« on: January 12, 2017, 11:02:14 pm »
I have attached a picture of the error that I get.
« Last Edit: January 13, 2017, 05:57:44 am by d4nn97 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
SFML compile c++
« Reply #1 on: January 12, 2017, 11:37:58 pm »
Because copy pasting the error was so much harder? ::)

If you link sfml-main you need to use the windows subsystem by adding the -mwindows flag.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

d4nn97

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML compile c++
« Reply #2 on: January 12, 2017, 11:45:37 pm »
Hi, I tried to add the flag but it still produces the same error

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SFML compile c++
« Reply #3 on: January 13, 2017, 12:10:41 am »
Also, don't create unnecessary polls. There's a big blue "NEW TOPIC" button for creating a new thread. ;)

Where did you add the flag?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

d4nn97

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML compile c++
« Reply #4 on: January 13, 2017, 12:13:59 am »
g++ -LC:\SFML\lib -o main.exe -o main.o -lsfml-graphics -lsfml-window -lsfml-system  -mwindows

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SFML compile c++
« Reply #5 on: January 13, 2017, 12:40:14 am »
So you removed sfml-main now? ::)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

d4nn97

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: SFML compile c++
« Reply #6 on: January 13, 2017, 12:43:02 am »
gcc -LC:\SFML\lib -o main.exe -o main.o -lsfml-graphics -lsfml-window -lsfml-system -lsfml-main -mwindows

d4nn97

  • Newbie
  • *
  • Posts: 6
    • View Profile
Cant compile sfml on windows
« Reply #7 on: January 13, 2017, 05:56:28 am »
g++ -IC:\SFML\include -c main.cpp -o main.o
g++ -LC:\SFML\lib -o main.exe -o main.o -lsfml-graphics -lsfml-window -lsfml-system  -lsfml-main -mwindows

I have compiled and tried to execute the program in this way but i get the following error

C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Cant compile sfml on windows
« Reply #8 on: January 13, 2017, 11:14:46 am »
Please don't create multiple topics...

You're using the -o flag twice when linking. The -o flag is for the output file and not for the object file, so you need to just provide the object file without -o flag.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

d4nn97

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Cant compile sfml on windows
« Reply #9 on: January 13, 2017, 05:49:12 pm »
Ok thank you. I was trying to move this to a better place thinking i could delete or move my previous post.

 

anything