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

Author Topic: undefined reference to 'WinMain@16'  (Read 4459 times)

0 Members and 1 Guest are viewing this topic.

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
undefined reference to 'WinMain@16'
« on: July 29, 2015, 02:02:34 am »
*EDIT* oops, I accudently posted this in the wrong forum. Does anyone know how to remove or move this post to 'help general forum'? Thanks




I did everything right. I built SFML using Cmake with MSYS configuration. Then I copied exact code from the tutorial which looks like this,


Code: [Select]
#include <SFML/Window.hpp>


int mian(){
    sf::Window window(sf::VideoMode(500, 400), "Window", sf::Style::None);
   
   
    while(window.isOpen()){
        sf::Event event;
       
        while(window.pollEvent(event)){
            if(event.type == sf::Event::Closed){
                window.close();
            }
        }
    }

    return 0;
}



This is my compilation...

Code: [Select]
g++ -std=c++11 window.cpp -o window.exe -L. -lsfml-main -lsfml-window -lsfml-
system

It gives me this error...

Code: [Select]
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):(.text.start
up+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
make: *** [all] Error 1



What's my problem?
« Last Edit: July 29, 2015, 02:27:10 am by yj1214 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10849
    • View Profile
    • development blog
    • Email
AW: undefined reference to 'WinMain@16'
« Reply #1 on: July 29, 2015, 02:25:53 am »
You link against sfml-main yet you don't set the sub-system to window. IIRC it's the flag -mwindow
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: undefined reference to 'WinMain@16'
« Reply #2 on: July 29, 2015, 03:24:16 am »
No effects...

Code: [Select]
g++ -std=c++11 window.cpp -o window.exe -L. -mwindows -lsfml-main -lsfml-window -lsfml-system
It gives me the same error...oh and is sfml-main necessary? what does it do?
« Last Edit: July 29, 2015, 09:46:33 am by yj1214 »

AlexxanderX

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • AlexanderX
Re: undefined reference to 'WinMain@16'
« Reply #3 on: July 29, 2015, 08:58:20 am »
I don't know if is typo but in the code instead of "int main()" is "int mian()".
Here you can find my blog and tutorials about SFML - http://alexanderx.net/ (died...) - http://web.archive.org/web/20160110002847/http://alexanderx.net/

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: undefined reference to 'WinMain@16'
« Reply #4 on: July 29, 2015, 09:45:35 am »
Oh, um... *facepalm...I spent my whole day to find the bug and it was because I misspelled... guess I gotta learn how to spell things. Thanks for the solution!
« Last Edit: July 29, 2015, 09:47:17 am by yj1214 »

 

anything