मैं एक पुस्तकालय लिख रहा हूं, जो मेरे मुख्य अनुप्रयोग में dlsym के साथ गतिशील रूप से लोड किया गया है।मुझे प्रतीक लुकअप त्रुटि क्यों मिल रही है?
library.h
#include <ilibrary.h>
#include <igateway.h>
class LibraryImpl;
class Library: public ILibrary {
public:
static ILibrary* instance();
IGateway* getGateway() const;
protected:
Library();
virtual ~Library();
private:
static ILibrary* instance_;
LibraryImpl* library_;
};
extern "C" {
IMPORT_EXPORT ILibrary* getLibrary();
}
library.cpp
#include "library.h"
#include "business/BCGateway.h"
class LibraryImpl {
public:
IGateway* getGateway();
};
IGateway* LibraryImpl::getGateway() {
return BCGateway::instance();
}
ILibrary* Library::instance_ = NULL;
ILibrary* Library::instance() {
return instance_ ? instance_ : (instance_ = new Library);
}
Library::Library() {
library_ = new LibraryImpl();
}
Library::~Library() {
delete library_;
}
IGateway* Library::getGateway() const {
return library_->getGateway();
}
extern "C" {
IMPORT_EXPORT
ILibrary* getLibrary(){
return Library::instance();
}
}
व्यापार/BCGateway.h
#include <igateway.h>
class BCGateway: public IGateway {
public:
static IGateway* instance();
protected:
BCGateway();
private:
static IGateway* instance_;
};
व्यापार/BCGateway.cpp
: मैं निम्नलिखित फ़ाइलें#include "BCGateway.h"
IGateway* BCGateway::instance_ = NULL;
IGateway* BCGateway::instance(){
return instance_ ? instance_ : (instance_ = new BCGateway);
}
मैं पुस्तकालय से कनेक्ट कर सकता हूं और लाइब्रेरी-उदाहरण को सफलतापूर्वक लोड कर सकता हूं। लेकिन जब मैं अपने मुख्य-अनुप्रयोग में कॉल पुस्तकालय> getGateway() मैं निम्नलिखित त्रुटि मिलती है:
symbol lookup error: ./gateways/libSwisscomXtraZone.so: undefined symbol: _ZN9BCGateway8instanceEv
तुम मुझे एक संकेत दे सकते हैं, मैं यह कैसे हल कर सकते हैं? मैं फँस गया हूँ।
धन्यवाद।
मेरी आखिरी टिप्पणी लिखी, मैंने देखा, कि मैं बस अपनी परियोजना फ़ाइल में BCGateway.h और BCGateway.cpp को जोड़ना भूल गया हूं, जिसमें से मेकफ़ाइल उत्पन्न होता है। तो इस वर्ग को वास्तव में मेरी पुस्तकालय में घोषित नहीं किया गया था। चूंकि मैं सी ++ पुस्तकालयों के लिए बहुत नया हूं, मैंने सोचा कि यह पुस्तकालय घोषणा के साथ एक मुद्दा है। आपकी सहायता के लिए धन्यवाद। –