error message when trying to build classes

Hi everyone, I am a newbie at programming and tired of trying to compile on visual studio i looked for an alternative a couple of days ago and code::blocks seems to be a good one, the thing is, the program runs brilliantly with small functions, but when i try to build a simple class, it gives me back the following error message:


-------------- Build: Debug in spain (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -I -c C:\Users\miguelangel\Desktop\train2game\spain\hola.cpp -o obj\Debug\hola.o
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'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 2 second(s))
1 error(s), 0 warning(s) (0 minute(s), 2 second(s))

now my three files are:

main.cpp:

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

int main()
{
hola ho;

cout << "hello world" << endl << endl;

return 0;
}
-------------------------

hola.h:

#ifndef HOLA_H
#define HOLA_H


class hola
{
public:
hola();
protected:
private:
};

#endif // HOLA_H

--------------------------

hola.cpp:

#include <iostream>
#include "hola.h"

using namespace std;

hola::hola()
{
cout << "alksjdf" << endl;
//ctor
}

--------------------

the project is set to be a console application, not a windows one, could anyone help me out with this please? i would really appreciate it as i feel like not trying to advance any deeper until i now what is happening here... thank you so much in advance

Teoras
You are compiling only hola.cpp and not main.cpp. Make sure that main.cpp is in the project file list and set to be built in its properties.
hi MiiNiPaa, thank you but i have just checked one by one and i got all three files with a check on compile file, to me is just not making any sense anymore... is really putting me off and is propably something really easy...
with a check on compile file
What about link? Both cpp files need to be linked together to work.
Yep mate all three are linked as well...
!. Header file should not be compiled nor linked.
Create new console project and add all three files to it.
noted, that is now unchecked and i added them both to a new console application project, still keeps giving me the exact same message:
-------------- Build: Debug in testing (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -I -c C:\Users\miguelangel\Desktop\train2game\testing\hola2.cpp -o obj\Debug\hola2.o
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'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 2 second(s))
1 error(s), 0 warning(s) (0 minute(s), 2 second(s))

Error message clearly shows that main.cpp is not compiling and linking. Does it propertires look like that: http://puu.sh/gkKYx/095d650ce1.png
yes, and 50 onpriority weight, i also tried changing it to 100...
And project it is in is displayed as current (bold letters)?
And you are using "build-all" button (or F9)?
yes to both...


Can you attach project cbp file somewhere? It is really strange, I literally just recreated your project and it works fine.
Hi there bud, sorry but i just finished work i could not reply before, well the thing now is this, when i arrived before i tried to send you the copy of my project, I decided to delete the whole thing and start again, but this time instead to doing it on the GNU GCC compiler i chose visual studio 2010 and did exactly the same and it worked, it even gave me back a value for a destructor!! why do you think was happening that now bearing in mind that it was probably due to the type of compiler?
I really appreciate your help mate, thanks very much :)
Maybe GCC wasn't installed properly? Or makefile got damaged.
sincerely don't know buddy, but well is alright now ;) thanks again for your help!! :)
Topic archived. No new replies allowed.