1

I'm pretty new to this stuff, and solutions from similar threads aren't working for me, so I'm asking again with my specific problem

I'm trying to compile a C++ program with a main() function on windows OS. So I used g++ -std=c++11 -o hw2 *.cpp

but I get this error when trying to compile

bin/ld.exe: c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-
w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `m
ain':
C:\temp\gcc\build-mingw-w64\mingw-w64-crt/../../src/mingw-w64-crt/crt/crt0_c.c:1
8: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
make: *** [all] Error 1

neither -mwindows or -mconsole flags solved this

Uriyasama
  • 31
  • 2
  • DId you define an `int main()`? If not what signature did you use for the `WinMain()`? If you used WinMain() did you enable UNICODE? With all of this said a 10 or so line [mcve] that we can test would be helpful. – drescherjm May 13 '21 at 22:19
  • 1
    My problem was actually that I accidently had two main functions... resolved :) – Uriyasama May 13 '21 at 22:50

0 Answers0