Author Topic: Whenever I add a class I get "Undefined reference to WinMain"  (Read 28048 times)

Offline JohnnyCrow

  • Single posting newcomer
  • *
  • Posts: 2
Re: Whenever I add a class I get "Undefined reference to WinMain"
« Reply #15 on: January 27, 2015, 06:03:02 pm »
Sorry for the late reply. Here's what you asked for:

1. I created a new project (just a console project).


2. Without changing any of the default code, I created a new class.


3. I added it to the current project.


4. I added the #include directive in main.cpp, and upon attempting to build the project, the 'undefined reference to WinMain@16' error appears.


5. I saved the project, closed it, and reopened it again.


6. When rebuilding the project, it works fine.


Not sure why this works, but closing the project and reopening it (or restarting Code::Blocks) solves the problem consistently.
"I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use." - Galileo Galilei

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Whenever I add a class I get "Undefined reference to WinMain"
« Reply #16 on: January 27, 2015, 06:16:13 pm »
Can someone else try these steps on windows and then tell me if the problem can be reproduced?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Whenever I add a class I get "Undefined reference to WinMain"
« Reply #17 on: January 27, 2015, 06:17:46 pm »
JohnnyCrow: Can you try to reproduce the bug using the latest nightly build?
Can you show the list of plugins you have enabled?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Whenever I add a class I get "Undefined reference to WinMain"
« Reply #18 on: January 27, 2015, 09:28:37 pm »
i can't reproduce this bug with a nightly (probably -10~20 commits) on win7

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Whenever I add a class I get "Undefined reference to WinMain"
« Reply #19 on: January 27, 2015, 10:45:02 pm »
BlueHazzard: Can you try with the 13.12 release?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Whenever I add a class I get "Undefined reference to WinMain"
« Reply #20 on: January 27, 2015, 10:58:06 pm »
Yop, here it is:

Code
-------------- Build: Debug in tmp4 (compiler: GNU GCC Compiler)---------------

[ 33.3%] mingw32-g++.exe -Wall -fexceptions -g -Wno-unused-local-typedefs -I -c G:\tmp\tmp4\main.cpp -o obj\Debug\main.o
[ 66.7%] mingw32-g++.exe -Wall -fexceptions -g -Wno-unused-local-typedefs -I -c G:\\tmp\tmp4\test.cpp -o obj\Debug\test.o
[100.0%] mingw32-g++.exe  -o bin\Debug\tmp4.exe obj\Debug\main.o obj\Debug\test.o   
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
 
Process terminated with status 0 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:

And yes it is the -I option.... don't know why it is there... and why saving helps, but someone has  fixed it in trunk...

[Edit:] saving project is not enough , you have to re open it, so the parser checks for plausibility...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Whenever I add a class I get "Undefined reference to WinMain"
« Reply #21 on: January 27, 2015, 11:26:23 pm »
Hm, thanks good to know it is fixed:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]