473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Undefined symbol vtable for <class name>

7
I did it again... after trashing the old code and trying to start simple, I receive the following error at compile (with g++, required)"

g++ main.cc
Undefined first referenced
symbol in file
vtable for Literal /var/tmp//ccBK9IR0.o
vtable for BooleanExp /var/tmp//ccBK9IR0.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

The code I am compiling is all located in one file (lines commented in main are trying to locate errors in headers):

Expand|Select|Wrap|Line Numbers
  1. // Second attempt
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. // Will be BooleanExp.h
  8.  
  9. class BooleanExp {
  10. public:
  11.     virtual ~BooleanExp();
  12.  
  13.     virtual bool GetValue();
  14.  
  15. protected:
  16.     BooleanExp();
  17.  
  18. };
  19.  
  20. // Will be BooleanExp.cc
  21.  
  22.  BooleanExp::BooleanExp() {};
  23.  
  24. // Will be Literal.h
  25.  
  26. class Literal : public BooleanExp  {
  27. public:
  28.     virtual ~Literal();
  29.  
  30. //protected:
  31.     Literal( bool * );
  32.  
  33. private:
  34.     bool _value;
  35.  
  36. };
  37.  
  38. // Will be Literal.cc
  39.  
  40. Literal::Literal(bool * v) {
  41.     _value = v;
  42. }
  43.  
  44.  
  45.  
  46. // Will be main.cc
  47.  
  48. int main() {
  49.  
  50. //Literal * a;
  51. //a = new Literal(0);
  52.  
  53. cout << "So far so good/n";
  54.  
  55. //delete a;
  56.  
  57. }
  58.  
  59.  
Again, any help would be greatly appreciated.

Tex
Oct 4 '08 #1
4 16942
weaknessforcats
9,208 Expert Mod 8TB
There is an error in this constructor:
Expand|Select|Wrap|Line Numbers
  1. Literal::Literal(bool * v) { 
  2.     _value = *v;         <--- you have v which is a bool*. _value is a bool.
  3.  
Other than that everything compiles OK but the actual member functions are not found by the linker I guess because you didn't send them along.
Oct 4 '08 #2
Tex08
7
I corrected the error you had pointed out, however I still cannot compile the program. All of the code is contained in one file for now (it will be broken apart as indicated in the code). Beside the few cout statements that were added, everything list below is contained in one file, main.cc:

Expand|Select|Wrap|Line Numbers
  1. // Second attempt
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. // Will be BooleanExp.h
  8.  
  9. class BooleanExp {
  10. public:
  11.     virtual ~BooleanExp();
  12.  
  13.     virtual bool GetValue();
  14.  
  15. protected:
  16.     BooleanExp();
  17.  
  18. };
  19.  
  20. // Will be BooleanExp.cc
  21.  
  22.  BooleanExp::BooleanExp() {cout << "In BooleanExp constructor\n";};
  23.  
  24. // Will be Literal.h
  25.  
  26. class Literal : public BooleanExp  {
  27. public:
  28.     virtual ~Literal();
  29.  
  30. //protected:
  31.     Literal( bool * );
  32.  
  33. private:
  34.     bool _value;
  35.  
  36. };
  37.  
  38. // Will be Literal.cc
  39.  
  40. Literal::Literal(bool * v) {
  41.     cout << "In Literal constructor\n";
  42.     _value = *v;
  43. };
  44.  
  45.  
  46.  
  47. // Will be main.cc
  48.  
  49. int main() {
  50.  
  51. //Literal * a;
  52. //a = new Literal(0);
  53.  
  54. cout << "So far so good/n";
  55.  
  56. //delete a;
  57.  
  58. }

in which upon compiling, I received:

Expand|Select|Wrap|Line Numbers
  1. g++ main.cc
  2. Undefined                       first referenced
  3.  symbol                             in file
  4. vtable for Literal                  /var/tmp//ccdlycaz.o
  5. vtable for BooleanExp               /var/tmp//ccdlycaz.o
  6. BooleanExp::~BooleanExp()           /var/tmp//ccdlycaz.o
  7. ld: fatal: Symbol referencing errors. No output written to a.out
  8. collect2: ld returned 1 exit status
  9.  
Any other suggestions?

Thank you again.
Oct 4 '08 #3
weaknessforcats
9,208 Expert Mod 8TB
All the code is not in your posting.

You are missing:

BooleanExp::GetValue()
BooleanExp::~BooleanExp()
Literal::~Literal()

I wrote some dummies and I got a good compiule and link.
Oct 4 '08 #4
Tex08
7
THANK YOU again...

After finding some other errors, it finally works.

Thanks again.
Oct 4 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Christopher | last post by:
I came across this line in a lib I am studing, it simply has class cSceneNode; all by itself. what is that line doing? I am used to seeing a declaration: MyClass test; or definition: class...
7
by: Dan Trowbridge | last post by:
He everyone, I am just getting started with .NET and I am having a porting problem. I get and error in code that lookssomething like this (really stripped down but you get the idea)... class...
11
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
1
by: MAILTONRK | last post by:
Hi, I am a Mainframe guy. I am working with MS access(maintaining a application) for the last 2 weeks. I had one master database and four replicas. One of my replica had trouble in...
4
by: Gary li | last post by:
Hi, all I find "template template" class cann't been compiled in VC6 but can ok in Redhat9. I write a test program like as: template< template<class> class T> class A { }; int main() {...
1
by: Birthe Gebhardt | last post by:
Dear all, I could not find the way to handle 'not normal' list objects, for example using remove_if, find etc. Example : class Todo { public : .. int getNumber(){ return num_;}
0
by: sphinney | last post by:
I have a complex Access 2002 database with multimple tables, queries, forms, and reports. The database is used by miltiple users that have one of four different levels of security. The databae uses...
10
by: jason.cipriani | last post by:
Is there any difference between declaring a template parameter as a "typename" or a "class"? E.g. template <class TT f() { } template <typename TT g() { } Thanks, Jason
2
by: =?Utf-8?B?Unlhbg==?= | last post by:
Hi, How can I get around runtime error that says I can not explicit cast List<SubClassto ICollection<Class>? Generic List inhertis generic ICollection and Subclass inherits Class, then...
4
by: smadadi | last post by:
When iam trying to save changes to some of the reports i am getting the error message as 'Couldn't save currently locked by user admin on machine <name>' happening with only some of the reports not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.