Linking Error Undefined Reference To Vtable
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site error undefined reference to vtable for qt About Us Learn more about Stack Overflow the company Business Learn more about the vtable symbol may be undefined because the class is missing its key function hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Undefined Reference To Vtable For Constructor
the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Linking error: undefined reference to
Undefined Reference To Vtable For C++
`vtable for XXX` up vote 11 down vote favorite 3 There is some linking error here. I looked for that online, yet still I couldn't find the problem. How can I fix it? g++ test.cpp -o test /tmp/ccDfCj4N.o: In function `Interval::Interval()': test.cpp:(.text._ZN8IntervalC2Ev[Interval::Interval()]+0x9): undefined reference to `vtable for Interval' /tmp/ccDfCj4N.o: In function `IntInterval::~IntInterval()': test.cpp:(.text._ZN11IntIntervalD0Ev[IntInterval::~IntInterval()]+0x1d): undefined reference to `Interval::~Interval()' /tmp/ccDfCj4N.o: In function `IntInterval::~IntInterval()': test.cpp:(.text._ZN11IntIntervalD1Ev[IntInterval::~IntInterval()]+0x1d): undefined reference to undefined reference to vtable qobject `Interval::~Interval()' /tmp/ccDfCj4N.o:(.rodata._ZTI11IntInterval[typeinfo for IntInterval]+0x10): undefined reference to `typeinfo for Interval' collect2: ld returned 1 exit status Here is the code! All classes are in a same file for a pilot program. #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Undefined Reference To `typeinfo For
policies of this site About Us Learn more about Stack Overflow the undefined reference to vtable for destructor company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags undefined reference to vtable for class c++ Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only http://stackoverflow.com/questions/7720205/linking-error-undefined-reference-to-vtable-for-xxx takes a minute: Sign up Linker Error: Undefined Reference to `vtable for square` up vote 0 down vote favorite 1 I've checked the most common undefined reference to vtable question on here, and while that gave me a better understanding of what is going on, I still wasn't able to gather enough information to figure out why I'm having this error. http://stackoverflow.com/questions/8830025/linker-error-undefined-reference-to-vtable-for-square I have a simple Square class, which, originally I was trying to inherit from a Polygon class. Since I've been relatively knew to C++ and still learning, I haven't experimented with Polymorphism all that much. Anyway, after I tried getting rid of the base class (Polygon), I thought that might help things. Unfortunately, I'm still getting the same error, and I don't quite know what is going on. What I do know is that originally, the Polygon class required a source file with at least a constructor definition, which I did give. That got rid of the vtable error for the Polygon class. My main issue is that I'm still getting this for the Square class, which was supposed to inherit from the Polygon class. What I'd like to know is how can I implement this properly to avoid getting a vtable error while still getting the benefits of Polymorphism? Code Polygon.h/.cpp #ifndef POLYGON_H #define POLYGON_H #include "Shape.h" #include "vector3f.h" class Polygon { public: Polygon(); virtual void Collide(Shape &s) = 0; virtual void Collide(Polygon &p) = 0; virtual bool
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this http://stackoverflow.com/questions/17865440/linker-error-undefined-reference-to-vtable site About Us Learn more about Stack Overflow the company Business Learn http://dragly.org/2010/01/03/fixing-undefined-reference-to-vtable-for/ more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Linker undefined reference Error undefined reference to vtable up vote 2 down vote favorite I seem to be having an issue with a wxWidgets project I'm working on. I keep getting a vtable linker error for a class that doesnt involve any virtual functions. I was wondering if someone could shed some light on this issue, since in my understanding there shouldnt be a vtable for a undefined reference to class that doesnt use virtual functions. Most similar topics I've seen occur when someone forgets the define the deconstructor, but I'm pretty sure the deconstructor was correctly defined. the errors can be seen below. ||=== Hike Planner GUI, Debug ===| obj\Debug\GUIFrame.o||In function `PlanWindow':| E:\Projects\Hike Planner GUI\GUIFrame.cpp|76|undefined reference to `vtable for PlanWindow'| E:\Projects\Hike Planner GUI\GUIFrame.cpp|76|undefined reference to `vtable for PlanWindow'| obj\Debug\GUIFrame.o||In function `~PlanWindow':| E:\Projects\Hike Planner GUI\GUIFrame.cpp|81|undefined reference to `vtable for PlanWindow'| E:\Projects\Hike Planner GUI\GUIFrame.cpp|81|undefined reference to `vtable for PlanWindow'| E:\Projects\Hike Planner GUI\GUIFrame.cpp|81|undefined reference to `vtable for PlanWindow'| ||=== Build finished: 5 errors, 0 warnings ===| segment from GUIFrame.h class PlanWindow : public wxWindow { DECLARE_EVENT_TABLE() public: PlanWindow(wxWindow* parent, wxWindowID id); ~PlanWindow(); void GetLocationList(int RetCode); wxListBox *PlanList; }; Segment from GUIFrame.cpp: PlanWindow::PlanWindow(wxWindow* parent, wxWindowID id) : wxWindow(parent,id) { } PlanWindow::~PlanWindow() { } void PlanWindow::GetLocationList(int RetCode) { if(RetCode == DEST) { } else if(RetCode == TH) { } else if(RetCode == FREE) { } else { } } any help at all would be great. the errors occur at the contructor and destructor definitions. c++ wxwidgets linker-error vtable share|improve this question asked Jul 25 '13 at 18:00 user2619631 80116 The
Qt and QML in the browser Using Blender and make-na to create DNA art An upcoming C++ library for HDF5 files Categories 3D Android Audio Biology Blender C++ CINPLA Computational Physics Copyleft Databases Efficiency Featured Games Gimp Graphics Hjernen HTML5 Inkscape Java Javascript LaTeX Mindseye Mobile MPI Music N900 N950 NetBeans Networking Nevrovitenskap Norsk Norwegian Other Personal Physics Programming Python Python Qt Ruby Security Status Straight from the source Technical Testing Tutorials TV Ubuntu Uncategorized Tagsandroid application auto mount automount blender C++ distribution enthought epd error errors game hosting Java LaTeX Linux mac maemo molecular dynamics monitor mount N900 NetBeans neuroscience norwegian opengl ovito physics Programming python qmake qml qt qt3d qt5.2 qt creator screen ssh terminal threading Ubuntu version version numbering web windows Meta Log in Entries RSS Comments RSS WordPress.org Blog content license except where specifically noted. Fixing "undefined reference to `vtable for …" These annoying errors have been haunting me the last couple of days, so I figured I should share the most common reason for their occurrence. That is in my projects at least. This error is caused because the linker in gcc is unable to find the functions you have defined in your headers in your actual code. So if you have a header which looks like this: #ifndef MESH_H #define MESH_H class Mesh { public: Mesh(); ~Mesh(); virtual void draw(); }; #endif // MESH_H You must at least have these functions defined in your .cpp file: #include "mesh.h" Mesh::Mesh() { } Mesh::~Mesh() { } void Mesh::draw() { } After this, make sure you clean your compile environment to make sure no object files are being misinterpreted by the compiler. If you are using Qt or a project with a Makefile, you could just run these three commands (the first only applies to Qt projects). qmake make clean make Should you still have trouble, make sure that qmake is actually generating your .moc files for any objects that need them. Sometimes it might even be necessary to empty the build directory completely yourself to make sure there are no files left behind that are not cleaned by make clean. Published by Svenn-Arne Dragly I'm a physicist and programmer, writing about the stuff I figure out as I go. View all posts