473,782 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

undefined reference to ,vtable for...

2 New Member
Hi,

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

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

source in separate header and cpp files as below.


/* DBConnectionFac tory.h */

#ifndef _DBCONNECTIONFA CTORY_H
#define _DBCONNECTIONFA CTORY_H
#include <iostream>
#include "DBConnecto r.h"
using namespace std;

class DBConnectionFac tory
{
public:
static DBConnector* getConnector(st ring&);
};

#endif /* _DBCONNECTIONFA CTORY_H */

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

/* DBConnectionFac tory.cpp */

#include "DBConnectionFa ctory.h"
#include "DBConnecto r.h"
#include "OracleConnecto r.h"

DBConnector* DBConnectionFac tory::getConnec tor(string& dbName)
{
DBConnector* factory;

if(dbName=="ora cle"){
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 _ORACLECONNECTO R_H
#define _ORACLECONNECTO R_H
#include <iostream>
#include "DBConnecto r.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 /* _ORACLECONNECTO R_H */

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

/* OracleConnector .cpp */

#include <iostream>
#include "OracleConnecto r.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 DBConnectionFac tory.cpp it gives folowing error(s).

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

Error:

/tmp/cc15eWsy.o: In function `OracleConnecto r::OracleConnec tor()':
DBConnectionFac tory.cpp:(.text ._ZN15OracleCon nectorC1Ev[OracleConnector ::OracleConnect or()]+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 4892
weaknessforcats
9,208 Recognized Expert Moderator Expert
This compiles fine with Visual Studio.NET 2008.
Feb 26 '09 #2
newb16
687 Contributor
You don't link OracleConnector .o with your DBConnectionFac tory, 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
chaturap
2 New Member
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
8481
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
2531
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 the link errors decreased from over 200 to 5. A great step! But one of my class derived from wxValidator can't be linked correctly though there is no any inline function in it. The error message: -----------------------
3
3462
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 function `TOpenAreaForm::TOpenAreaForm(TControl*)':
9
3016
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 of a class and that concerns virtual functions. What does it mean?
7
1090
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 MessageQueue.cpp MessageFragmenter.cpp SingleMessage.cpp /tmp/ccsrT4jU.o(.gnu.linkonce.t._ZN9c_ServiceD1Ev+0xb): In function `c_Service::~c_Service ()': : undefined reference to `vtable for c_Service'
9
9666
by: jimjim | last post by:
Hello all, class Base { public: virtual void f(); }; class Derived : public Base{ private: int i; };
4
5881
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
2818
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 pointers. Iam getting errors like 1. In function TOP::TOP(int) : undefined reference to CHILD1::CHILD1(int, float). 2. In function TOP::TOP(int) : undefined reference to vtt for CHILD2::CHILD2(char*)
5
11361
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 to pass all the necessary object files to the linker. Neither of those are my problem. Please bear with me as the question I ask is rather long and I think it's beyond a CS101 level of linker stupidity. If it is a stupid CS101 mistake I'm making...
2
2175
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' foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x19): In function `CFoo::CFoo()': : undefined reference to `CFoo::rmap' foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x30): In function `CFoo::CFoo()':
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9942
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7492
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.