Code::Blocks not compiling with header files

Good evening! (morning?)

I was wondering if anyone is familiar with the following issues. There are three files here, which are Cat.cpp, Cat.h, and CatMain.cpp. The issues are as follows:

When I try to build Cat.cpp, I get the error "undefined reference to WinMain@16".

When I try to build CatMain.cpp, I get undefined reference errors for the speak and jump functions.

The files are in the same folder and the code is just one-liners:

Cat.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include "Cat.h"

using namespace std;

void speak()
{
    cout << "meow" << endl;
}

void jump()
{
    cout << "meow?" << endl;
}


Cat.h

1
2
3
4
5
6
7
#ifndef CAT_H
#define CAT_H

void speak();
void jump();

#endif // CAT_H 


CatMain.cpp

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include "Cat.h"

using namespace std;

int main()
{
    speak();
    jump();
    return 0;
}


Is there anything wrong with this code? Or is anyone aware of whether or not this is a Code::Blocks or a compiler issue?

Any help is greatly appreciated =)
your linker is searching for WinMain function which you do not have. instead you have main()

You need to check linker settings in Code::Blocks, and change the entry point setting from WinMain to main.

edit:
I do not have C::B but I think it's /entry in the additional linker options
try to clear this entry first and see if that works.
Last edited on
Nevermind, it works now for some reason. Did the same thing but only worked the second time. Thanks for the heads up though!
Topic archived. No new replies allowed.