Author Topic: undefined reference to `WinMain@16 help  (Read 15128 times)

_k0rn_

  • Guest
undefined reference to `WinMain@16 help
« on: February 19, 2014, 03:25:01 am »
||=== Build: Debug in korn (compiler: GNU GCC Compiler) ===|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libmingw32.a(main.o):main.c:(.text.startup+0xa7)||undefined reference to `WinMain@16'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

i am getting that

when i make a normal simple class it works fine but when i add another class , then i get that error


got
 main.cpp
-----------------
#include <iostream>
#include "hannah.h"
using namespace std;


int main()
{

Hannah ho(23);

 ho.printCrap();

}


hannah.h
---------


#ifndef HANNAH_H
#define HANNAH_H


class Hannah
{
    public:
        Hannah(int);
         void printCrap();
    private:
         int h;
};

#endif // HANNAH_H

hannah.cpp
----------

#include <iostream>
#include "hannah.h"
using namespace std;

Hannah::Hannah(int num)
 :h(num)

{

}
 void Hannah::printCrap(){


cout << "h=" << h << endl;
cout << "this->" << this->h << endl;
cout << "(*this).h=" << (*this).h << endl;
 }


i try everything and that stupid error wont go away , so can someone plz explain what i did wrong or a way to fix it , i am using  console application , with cnu gcc compiler

with code blocks 13.12 , hopes that all the info yall need to help me.



Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: undefined reference to `WinMain@16 help
« Reply #1 on: February 19, 2014, 11:50:26 am »
Hi,
1) Use code tags ( the 10th icon in the second row) to post code and build logs
2) please post the full build log. You can use this template http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

it seems you are either building this as gui or you are removing the main() function from your build chain. Do you use a project?

greetings