0

I tried to compile a simple win32 API program. And for some reason that I can't seem to get fixed, I get a compilation error in the Clion IDE which I usually use for coding. But the same code run perfectly fine with the visual studio IDE. Now I really want to fix that problem so I can understand a little bit more of how things work in the background and also because I don't want to get use to a different IDE from what I already use to. The code is the example from here: https://learn.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program

I didn't try anything actually due to the fact I couldn't find any sort of help on the web for my problem.

this is the errors I get:

C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): In function `main':
C:/crossdev/src/mingw-w64-v4-git/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\untitled4.dir\build.make:84: recipe for target 'untitled4.exe' failed
mingw32-make.exe[3]: *** [untitled4.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/untitled4.dir/all] Error 2
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/untitled4.dir/all' failed
CMakeFiles\Makefile2:83: recipe for target 'CMakeFiles/untitled4.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/untitled4.dir/rule] Error 2
Makefile:117: recipe for target 'untitled4' failed
mingw32-make.exe: *** [untitled4] Error 2
BenGababy
  • 11
  • 2
  • I read the post and I couldn't understand from it what to do to fix my problem... – BenGababy Aug 19 '19 at 15:30
  • Please provide a [mcve]. Why does the error say `In function `main':`? Does your code contain a function called `main`? – Thomas Sablik Aug 19 '19 at 15:35
  • I posted a link to the exact code. and no my program doesn't have a function main. here is the link again: https://learn.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program – BenGababy Aug 19 '19 at 15:53
  • That's not a compiler error. That's a linker error. – IInspectable Aug 19 '19 at 16:37
  • ok but how to fix it?... – BenGababy Aug 19 '19 at 18:29
  • Did you use the same compiler/linker in both IDEs? Is the project type different? You can try: https://stackoverflow.com/questions/2753761/how-do-i-tell-cmake-not-to-create-a-console-window – Thomas Sablik Aug 19 '19 at 20:53
  • [From win32-apps-with-mingw](https://www.transmissionzero.co.uk/computing/win32-apps-with-mingw/) _One thing to note is that Visual C++ supports a “wWinMain” entry point where the “lpCmdLine” parameter is a “LPWSTR”. ... However, the MinGW CRT startup library does not support wWinMain, so you’ll have to stick with the standard “WinMain” and use “GetCommandLine()” if you need to access command line arguments._ – Daniel Sęk Aug 20 '19 at 07:09

0 Answers0