473,397 Members | 1,969 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,397 software developers and data experts.

undefined reference to ,vtable for...

Hi,

I'm trying to implement factory method pattern using C++ on Ubuntu 8.04 using gcc 4.2.

There are 3 major classes DBConnectionFactory, DBConnector and OracleConnector (which is the derived class of DBConnector).

source in separate header and cpp files as below.


/* DBConnectionFactory.h */

#ifndef _DBCONNECTIONFACTORY_H
#define _DBCONNECTIONFACTORY_H
#include <iostream>
#include "DBConnector.h"
using namespace std;

class DBConnectionFactory
{
public:
static DBConnector* getConnector(string&);
};

#endif /* _DBCONNECTIONFACTORY_H */

//================================================== ==========

/* DBConnectionFactory.cpp */

#include "DBConnectionFactory.h"
#include "DBConnector.h"
#include "OracleConnector.h"

DBConnector* DBConnectionFactory::getConnector(string& dbName)
{
DBConnector* factory;

if(dbName=="oracle"){
factory = new OracleConnector();
}
else{
exit(1);
}
if(factory==0){
exit(1);
}
else{
return factory;
}
}

//================================================== ==========

/* DBConnector.cpp */

#ifndef _DBCONNECTOR_H
#define _DBCONNECTOR_H
#include <iostream>
using namespace std;

class DBConnector
{
public:
// Pure virtual methods. Derived class(es) should implement these methods
virtual void init() = 0;
virtual void connect() = 0;
virtual void shutdown() = 0;

virtual ~DBConnector()
{

}
};

#endif /* _DBCONNECTOR_H */


//================================================== ==========

/* OracleConnector.h */

#ifndef _ORACLECONNECTOR_H
#define _ORACLECONNECTOR_H
#include <iostream>
#include "DBConnector.h"
#include <occi.h>

using namespace std;
using namespace oracle::occi;

class OracleConnector : public DBConnector
{
private:
// commented...

public:
void init();
void connect();
void shutdown();
};

#endif /* _ORACLECONNECTOR_H */

//================================================== ==========

/* OracleConnector.cpp */

#include <iostream>
#include "OracleConnector.h"

using namespace std;

void OracleConnector::init(){
// code...
}

void OracleConnector::connect(){
// code...
}

void OracleConnector::shutdown(){
// code...
}

int main(){} // TODO: Remove this main() added for testing

When I try to compile DBConnectionFactory.cpp it gives folowing error(s).

Command: g++ DBConnectionFactory.cpp -I/opt/oracle/include -L/opt/oracle/lib -locci -lclntsh

Error:

/tmp/cc15eWsy.o: In function `OracleConnector::OracleConnector()':
DBConnectionFactory.cpp:(.text._ZN15OracleConnecto rC1Ev[OracleConnector::OracleConnector()]+0x16): undefined reference to `vtable for OracleConnector'
collect2: ld returned 1 exit status

I went through GCC FAQs but could not figure out the reason. Highly appreciate your feedback.

Thanks,

Chatura
Feb 26 '09 #1
3 4862
weaknessforcats
9,208 Expert Mod 8TB
This compiles fine with Visual Studio.NET 2008.
Feb 26 '09 #2
newb16
687 512MB
You don't link OracleConnector.o with your DBConnectionFactory, but reference OracleConnector in it when create it
factory = new OracleConnector();

It compiles ok if you merge all this stuff in one cpp file.
Feb 26 '09 #3
Thanks for replying... I will try
Feb 27 '09 #4

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

Similar topics

1
by: Daniel Heiserer | last post by:
Hi, I got the following compiling/linking error, but I have no clue what it is about. Can anybody help me? thanks, daniel
2
by: Quansheng Liang | last post by:
Hello, I struggled with the problem of "undefined reference to `vtable ...`" while migrating a project from windows to linux. After searching the google I removed all the inline functions and now...
3
by: bp | last post by:
Hi, Could someone to tell me what I'm doing wrong? I'm using gcc version 3.3.4 and ld version 2.15.90.0.3 20040415 the linker message is: .../obj/classOpenAreaForm.o(.text+0x211): In...
9
by: alessandro | last post by:
Compiling my current project I received the following error: undefined reference to `vtable for Tuner' The only two things I know are that the error occours when trying to invoke the constructor...
7
by: Karl Ebener | last post by:
Hi! I have created a program using several classes with inheritage. When I compile and link, I get the following error: :$ g++ service2.cpp Service.cpp Application.cpp Message.cpp...
9
by: jimjim | last post by:
Hello all, class Base { public: virtual void f(); }; class Derived : public Base{ private: int i; };
4
by: Mark | last post by:
Hi, I'm trying to write some classes that kind of manage themselves. A linked list, that links different types of objects. Here's the code... object.h: --- class Object { int alt;
5
by: pavan734 | last post by:
Hi, Iam facing problem with undefined reference linking errors. To explain in more detail.. I have a class called TOP. In its constructor I have instantiated many other class objects using...
5
by: druberego | last post by:
I read google and tried to find the solution myself. YES I do know that you can get undefined references if you: a) forget to implement the code for a prototype/header file item, or b) you forget...
2
by: boyphp | last post by:
I'm getting the following undefined reference errors: foo_test.o(.gnu.linkonce.t._ZN7CFooD1Ev+0x18): In function `CFoo::~CFoo()': : undefined reference to `vtable for CFoo'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.