undefined reference to `vtable'?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Nine_Masquerade_
Posts: 26
Joined: Thu Jun 18, 2009 10:30 am

undefined reference to `vtable'?

Post by Nine_Masquerade_ »

When compiling i get this error log:


**** Build of configuration Default for project ITAWAS ****

make all
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -L. -LC:/pspsdk/psp/sdk/lib main.o graphics.o framebuffer.o -lpspgu -lpng -lz -lm -lstdc++ -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o hello.elf
main.o: In function `main':
main.cpp:(.text+0x7c): undefined reference to `vtable for Shop'
main.cpp:(.text+0x84): undefined reference to `vtable for Shop'
collect2: ld returned 1 exit status
make: *** [hello.elf] Error 1

here is how i declared shop in main.c:

Code: Select all

	Shop *shop;
	shop = new Shop;
Here is Shop.h:

Code: Select all

#pragma once
#include <string>
#include <vector>

//#include "Player.h"


class Shop
&#123;
public&#58;
	Image *BG;
	Image *img;

	int WIDTH;
	int Y;
	int X0;

	int X1;

	int X2;

	int X3;

	int X4;

	bool firstPass;

	int xCoordinates&#91;5&#93;;
	bool inventory&#91;5&#93;&#91;10&#93;;
	int costs&#91;5&#93;&#91;10&#93;;
	int arrowCoords&#91;5&#93;&#91;10&#93;;

	int left;

	int right;

	int still;

	int dir;

	int current;

	int dis;

	int choice;
	int selectedUpgrade;
	int numUp;

	std&#58;&#58;string side;


	//0 = image, 1 = stats

	std&#58;&#58;vector<Image*> shotgun;

	std&#58;&#58;vector<Image*> minigun;

	std&#58;&#58;vector<Image*> uzi;

	std&#58;&#58;vector<Image*> flamethrower;

	std&#58;&#58;vector<Image*> dragown;

	std&#58;&#58;vector<Image*> money;
	Image *pointer;
	Image *incr;


	std&#58;&#58;vector<std&#58;&#58;vector<Image*>*> weapon;


	std&#58;&#58;vector<Image*> upgrades;

	std&#58;&#58;vector<Image*> display;

	//Arrows 0,1 = Left 2,3 = Right

	std&#58;&#58;vector<Image*> arrow;


	std&#58;&#58;vector<Image*> fist;

	std&#58;&#58;vector<Image*> heart;

	Shop&#40;&#41;;
//
	virtual void draw&#40;&#41;;
//
	virtual bool act&#40;bool L, bool R, bool U, bool D, bool E, bool esc&#41;;
&#125;;
Here is Shop.cpp:

Code: Select all

#include "Shop.h"

Shop&#58;&#58;Shop&#40;&#41;
&#123;
code
&#125;

void Shop&#58;&#58;draw&#40;&#41;
&#123;
code
&#125;

bool Shop&#58;&#58;act&#40;bool L, bool R, bool U, bool D, bool E, bool esc&#41;
&#123;
code
&#125; 
Thanks for any help.
slasher2661996
Posts: 91
Joined: Sun Feb 22, 2009 8:32 am
Location: Melbourne Australia ZOMG

Post by slasher2661996 »

Shop shop = new Shop();
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

slasher2661996 wrote:Shop shop = new Shop();
I'm sorry but :

Code: Select all

Shop *shop = new Shop;
is perfectly valid and should not be the issue. And you're plainly wrong without "*".

@OP: It seems Shop.o is missing in your OBJS flag (Makefile), so it cannot resolve the address of your VMT which is normally defined in Shop.o.
slasher2661996
Posts: 91
Joined: Sun Feb 22, 2009 8:32 am
Location: Melbourne Australia ZOMG

Post by slasher2661996 »

really? i was reading the error wrong, sorry :/
Post Reply