Sign in to follow this  
Slyfox

Dec-C++ error message

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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);
}

Share this post


Link to post
Share on other sites
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???

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
haha I'll give it to you, you are pedantic in you replies!

Have you never had a situation where you are writing a piece of code, come across errors and can't figure out where they are after searching for a lengthy period of time, you just want a quick solution so that you may carry on with the next thing that you are trying to do? A search on google could just add another 30 mins of searching and in this situation probably wouldn't have helped me discover the typo in my code!

Share this post


Link to post
Share on other sites
Quote:
Original post by Slyfox
haha I'll give it to you, you are pedantic in you replies!

Have you never had a situation where you are writing a piece of code, come across errors and can't figure out where they are after searching for a lengthy period of time, you just want a quick solution so that you may carry on with the next thing that you are trying to do? A search on google could just add another 30 mins of searching and in this situation probably wouldn't have helped me discover the typo in my code!


You know what, I will make a point of not answering any of your questions on this or any other board.
You insult me, think I am talking crap and then can't be bothered to spend "30 mins" looking for a solution or a reason for the problem on google, rather you want someone else to solve it for you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this