Dec-C++ error message

Started by
10 comments, last by CmpDev 17 years, 6 months ago
Hey, Ok I'm trying to compile a simple program which is a tutorial from a book, already had to debug a load of other errors, but I'm stumped on this one! All it says is: [Linker error] undefined reference to 'GameDeactivate(HWND_*)' Does anyone have any idea how to fix this error? Many thanks!
Advertisement
Yes what you want to do it go down the road, take the second left and then the first right after the sign which says "are you for real?".

I'm begining to think this link maybe a good signature:
http://www.catb.org/%7Eesr/faqs/smart-questions.html
It means you promised the compiler/linker that there would be a function named GameDeactivate that took as a parameter a HWND (HWND will be a typedef of HWND_ *) by providing a forward declaration of the form:

void GameDeactivate(HWND);

But you never actually provided the implementation of the function, i.e.:

void GameDeactivate(HWND hwnd)
{
// code
}

An "undefined reference" always means that you declared something but the compiler never saw a matching definition.

Σnigma
Quote:Original post by CmpDev
Yes what you want to do it go down the road, take the second left and then the first right after the sign which says "are you for real?".

I'm begining to think this link maybe a good signature:
http://www.catb.org/%7Eesr/faqs/smart-questions.html


Was that really necessary? Sure his post has some typos, but it's still better than 99.9999999% of most of the stuff on the Internet. Don't be a dick.

Slyfox, you're getting that error because you don't actually have a function called GameDeactivate with those parameters. See all the compiler does is see if you have a function defined, but waits to the linker stage to put in the actual implementation. Look through your book, find the function and add it in where it's supposed to go. Also copying code right out of the book is asking for trouble, it's suppose to teach you, then you write your own implementation.
Thanks for a useful response, unlike the first clown...

here's the thing tho, I believe i did provide the matching definition?!

void GameDeactive(HWND hWindow)
{
HDC hDC;
RECT rect;

// Draw deactivate text on the game screen
GetClientRect(hWindow, &rect);
hDC = GetDC(hWindow);
DrawText(hDC, TEXT("The blizzard has passed."), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
ReleaseDC(hWindow, hDC);
}
undefined reference to 'GameDeactivate(HWND_*)'
void GameDeactive(HWND hWindow)

Σnigma
Quote:Original post by Scet
Quote:Original post by CmpDev
Yes what you want to do it go down the road, take the second left and then the first right after the sign which says "are you for real?".

I'm begining to think this link maybe a good signature:
http://www.catb.org/%7Eesr/faqs/smart-questions.html


Was that really necessary? Sure his post has some typos, but it's still better than 99.9999999% of most of the stuff on the Internet. Don't be a dick.

Slyfox, you're getting that error because you don't actually have a function called GameDeactivate with those parameters. See all the compiler does is see if you have a function defined, but waits to the linker stage to put in the actual implementation. Look through your book, find the function and add it in where it's supposed to go. Also copying code right out of the book is asking for trouble, it's suppose to teach you, then you write your own implementation.


OK. How much effort have you done on your own behalf to solve the problem?
Google only gives 14 million hits for "undefined reference"!
Quote:simple program
Which program
Quote:which is a tutorial from a book
OK which book.
Quote:already had to debug a load of other errors
Maybe this has caused the error.

Quote:unlike the first clown...

You make a post with very little info (I bet you don't even read the link!) and because you called me it then I will return the pleasure. Look at Enigma's post clown.

As for Scet's comment
Quote:Don't be a dick.

Hmm yep the info which was required to solve the problem was present in the first post wasn't it???
Are you sure it's being included with the project? It's possible to have files open in Dev-C++, but that don't actually get linked with the rest. How does your project look? Is this in a .h or .c/.cpp file?

Edit: Nevermind, Enigma got it.

Quote:Original post by CmpDev
OK. How much effort have you done on your own behalf to solve the problem?
Google only gives 14 million hits for "undefined reference"!


I don't know which one of us you're addressing, but it doesn't matter. When someone asks for help, you're suppose to help them if you know the answer, not act like a jerk.
Thanks guys, got it sorted I've been staring at the same piece of code for too long now and didn't notice it thanks.

BTW CmpDev i did look at the link - if I didn't provide enough information, how come the problem was solved very quickly by the other guys? This is a beginner forum meaning you should be able to use it without recieving abuse from other people, all it would have taken was for you to ask for more information and I would have provided it I appreciate you taking time to look through the posts to try and help, but you need to ask yourself "Am I actually helping?" before you write a reply.
Quote:Original post by Slyfox
Thanks guys, got it sorted I've been staring at the same piece of code for too long now and didn't notice it thanks.

BTW CmpDev i did look at the link - if I didn't provide enough information how come the problem was solved very quickly by the other guys? This is a beginner forum mean you should be able to use it without recieving abuse from other people, all it took was for you to ask for more information and I would have provided it I appreciate you taking time to look through the posts to try and help, but you need to ask yourself "Am I actually helping?" before you write a reply.


Ok lets brake that down, it may help you.

Quote:if I didn't provide enough information how come the problem was solved very quickly by the other guys?

You made another post with more information which was relevent. If you had done a search first of all, the first couple of replies would not have been anything new to you and you wouldn't have needed to make the second post.

Quote:This is a beginner forum mean you should be able to use it without recieving abuse from other people

I did not give you abuse, infact it was you.

Quote:all it took was for you to ask for more information and I would have provided

If you read the link then maybe you would realise what I was saying, you have not provided enough info and/or havn't tried to solve this for yourself.

Quote:but you need to ask yourself "Am I actually helping?" before you write a reply.

So just giving answers to things is the only help which I can offer. What about you need to do some work for yourself and this will help you far far more.
Was I helping? Yes I showed you a link about asking questions.

This topic is closed to new replies.

Advertisement