Jump to content
  • Advertisement
Sign in to follow this  
yaazz

undefined reference to vtable

This topic is 4230 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

***EDIT: oops, ]code[ supposed to be ]source[ tags, I appologize I am using Eclipse C/C++ on Ubuntu Linux. When I tried to create this class (an Input class for GLUT), it gives me an "undefined reference to `vtable for soabiro_Input'" error. Does anyone know what this is and how I fix it? here is my code Soabiro_Input.h
#ifndef sOABIRO_INPUT_H_
#define sOABIRO_INPUT_H_
  
class soabiro_Input
{ 
	bool keyUp,keyDown,keyLeft,keyRight;
	bool leftClick,rightClick,middleClick;
	int key[256];
	int windowH,windowW; //height and width of screen window, used to get proper coordinates
	double mouseX,mouseY;
	int mouseBtn,mouseState; 

public:
	soabiro_Input();
	soabiro_Input(int W, int H); 
	void keyboard(unsigned char key, int x, int y);
	void specialKeyboard(int key, int x, int y);
	void mouseMove(int x, int y);
	void mouseClick(int btn, int state, int x, int y);
	

	virtual ~soabiro_Input();
};

#endif /*SOABIRO_INPUT_H_*/

Soabiro_Input.cpp

#include <GL/glut.h>
#include <iostream>
#include "soabiro_Input.h"

	soabiro_Input::soabiro_Input()
	{
		std::cout << "WARNING, using default constructor for Input class, mouse coordinates \n";
		std::cout << "will be calibrated for a window that is 640 * 480!!! \n";
		windowW=640;
		windowH=480;
	}
	
	soabiro_Input::soabiro_Input(int W, int H)
	{
		windowW=W;
		windowH=H;
	}

	void soabiro_Input::keyboard(unsigned char key, int x, int y)
	{
	}
	void soabiro_Input::specialKeyboard(int key, int x, int y)
	{
		//left arrow
		if (key == GLUT_KEY_LEFT)
			keyLeft=true;
		else
			keyLeft=false;
	
		//right arrow
		if (key == GLUT_KEY_RIGHT)
			keyRight=true;
		else
			keyRight=false;
	
		//up arrow
		if (key == GLUT_KEY_UP)
			keyUp=true;        
		else
			keyUp=false; 
	
		//down arrow
		if (key == GLUT_KEY_DOWN)
			keyUp=true;        
		else
			keyUp=false; 
	}
	void soabiro_Input::mouseMove(int x, int y)
	{
		/*gets mouse coordinates and converts them to a num between -1 and 1 for OpenGL*/
		mouseX=(float)x;
		mouseX=((mouseX / windowW)*2)-1;
		mouseY=(float)y;
		mouseY=((mouseY / windowH)*2)-1;

	}
	void soabiro_Input::mouseClick(int btn, int state, int x, int y)
	{
		//get mouse button and state
		mouseBtn=btn;
		mouseState=state;
		
		//get coordinates in opengl format (-1 to 1)
		mouseX=(float)x;
		mouseX=((mouseX / windowW)*2)-1;
		mouseY=(float)y;
		mouseY=((mouseY / windowH)*2)-1;
	}



Share this post


Link to post
Share on other sites
Advertisement
That error occurs when you don't implement a virtual function. In your case it is the virtual destructor. Assuming that the destructor body is empty, just replacing "virtual ~soabiro_Input();" with "virtual ~soabiro_Input(){}" should fix it.

Share this post


Link to post
Share on other sites
where is the definition of your destructor?! or are you creating an abstract destructor and forgot to declare it like virtual ~soabiro_Input()=0; ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!