Snekgame unresolved externals

The Partridge Family were neither partridges nor a family. Discuss.
misterchi
Posts: 20
Joined: November 12th, 2016, 3:15 pm

Re: Snekgame unresolved externals

Post by misterchi » March 28th, 2017, 5:18 pm

Hi,

I added the code.

Thanks!
Attachments
snekgame.zip
(603.53 KiB) Downloaded 180 times

misterchi
Posts: 20
Joined: November 12th, 2016, 3:15 pm

Re: Snekgame unresolved externals

Post by misterchi » March 29th, 2017, 5:44 pm

Hi Chili,

I added the snek. Thx!
Attachments
snekgame.zip
(603.53 KiB) Downloaded 160 times

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snekgame unresolved externals

Post by albinopapa » March 29th, 2017, 6:31 pm

Snek Tutorial 14a at 28 min 55 sec

At this point in the video chili creates the definitions for the functions you are missing.

Unresolved externals usually means that the compiler can't find a variable or function that is being used or called. In this case, it's all the Snake::Segment functions that you did not define. You have them declared, but not defined and the Snake functions call some of them like Snake::Segment::MoveBy and Snake::Segment::Segment. Which means the compiler is being asked to use some code that it can't find, and it is telling you that you must be crazy.

Finish the video and define all the rest of the functions and see if that helps.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snekgame unresolved externals

Post by albinopapa » March 29th, 2017, 6:43 pm

Oh, just found another issue you were having is the Snake::Snake having issues with missing Snake::Segment::Segment. It's because you added a constructor to Location ( which chili did not add ). Since you added a constructor, the compiler doesn't implicitly add the default constructor to Location. Which means Snake::Segment::Location loc needs to be initialized using a Snake::Segment::Segment constructor.

You have a few options:
Delete the constructor you made from Location
Add a default constructor to Location ( Location() = default; )
Add a constructor to Segment that initializes Snake::Segment::Location loc
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snekgame unresolved externals

Post by albinopapa » March 29th, 2017, 7:09 pm

Hopefully the version you downloaded has the SpriteCodex.h and SpriteCodex.cpp files, because the one you posted does not.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

misterchi
Posts: 20
Joined: November 12th, 2016, 3:15 pm

Re: Snekgame unresolved externals

Post by misterchi » March 30th, 2017, 12:28 pm

Tanks Albinopapa,I deleted the constructor for location. Now it works fine. But I still have a question:
I dont understand why this: "Location loc = { x,y };" works because how does Visual Studio know which variables I want to change in loc object?

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snekgame unresolved externals

Post by albinopapa » March 30th, 2017, 1:05 pm

Well, the {x,y} creates a temporary Location by storing each variable consecutively in memory, then assigns that data to Location loc. So if you had done Location loc = {y, x} loc.x would have been what your y was and loc.y would have been what your x was when you passed them in.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

misterchi
Posts: 20
Joined: November 12th, 2016, 3:15 pm

Re: Snekgame unresolved externals

Post by misterchi » March 30th, 2017, 8:03 pm

Cool, maybe it's a stupid question, but how does the computer know that when I write Location loc = {x,y}; I want the x to be stored in loc.x and not in loc.y or in any other variable?

misterchi

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Snekgame unresolved externals

Post by LuisR14 » March 30th, 2017, 8:19 pm

it's done according to the order in which you declare the variables in the class/struct :)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Snekgame unresolved externals

Post by albinopapa » March 30th, 2017, 10:56 pm

misterchi wrote:Cool, maybe it's a stupid question, but how does the computer know that when I write Location loc = {x,y}; I want the x to be stored in loc.x and not in loc.y or in any other variable?

misterchi
Yeah, I kind of explained that already.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply