我正在做一个来自 CLucene 的小包装器。
ofxCLucene.h
#ifndef _OFXCLUCENE_
#define _OFXCLUCENE_
#include "ofMain.h"
#include "ofxXmlSettings.h"
#include "ofxDirList.h"
#include "CLucene.h"
using namespace lucene;
using namespace lucene::analysis;
using namespace lucene::analysis::standard;
using namespace lucene::index;
using namespace lucene::document;
using namespace lucene::queryParser;
using namespace lucene::search;
using namespace lucene::store;
class ofxCLucene {
private:
string name;
SimpleAnalyzer *sanalyzer;
Directory *dir;
IndexWriter *writer;
IndexReader *reader;
public:
ofxCLucene(string name);
~ofxCLucene();
void addDocumentsFromDirectory(string pathToDir);
void addDocumentXML(ofxXmlSettings *docXML);
void indexReader();
void closeIndex();
Hits* search(string query);
};
#endif
ofxCLucene.cpp
#include "ofxCLucene.h"
//------------------------------------------------------------------------------
ofxCLucene::ofxCLucene(string name) {
this->name = name;
sanalyzer = new SimpleAnalyzer();
}
...
我编译它没有问题,但是当我把它放在我的项目中并创建一个新对象时,我得到了错误:
"vtable for lucene::analysis::Analyzer", referenced from:
__ZTVN6lucene8analysis8AnalyzerE$non_lazy_ptr in ofxCLucene.o
(maybe you meant: __ZTVN6lucene8analysis8AnalyzerE$non_lazy_ptr)
"vtable for lucene::analysis::SimpleAnalyzer", referenced from:
__ZTVN6lucene8analysis14SimpleAnalyzerE$non_lazy_ptr in ofxCLucene.o
(maybe you meant: __ZTVN6lucene8analysis14SimpleAnalyzerE$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status
两者的源代码是:
class Analyzer:LUCENE_BASE{
public:
virtual TokenStream* tokenStream(const TCHAR* fieldName, CL_NS(util)::Reader* reader)=0;
virtual ~Analyzer(){
}
virtual int32_t getPositionIncrementGap(const TCHAR* fieldName);
};
class SimpleAnalyzer: public Analyzer {
public:
TokenStream* tokenStream(const TCHAR* fieldName, CL_NS(util)::Reader* reader);
~SimpleAnalyzer(){}
};
我认为这是一个命名空间问题,我尝试调用
analyzer::SimpleAnalyzer *sanalyzer = new analyzer::SimpleAnalyzer();
但问题仍然存在。
建议?谢谢