c++ - Linking problem with wrapper for CLucene -
i'm doing small wrapper 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(); } ...
i have no problem compile when put on project , create new object got errors:
"vtable lucene::analysis::analyzer", referenced from: __ztvn6lucene8analysis8analyzere$non_lazy_ptr in ofxclucene.o (maybe meant: __ztvn6lucene8analysis8analyzere$non_lazy_ptr) "vtable lucene::analysis::simpleanalyzer", referenced from: __ztvn6lucene8analysis14simpleanalyzere$non_lazy_ptr in ofxclucene.o (maybe meant: __ztvn6lucene8analysis14simpleanalyzere$non_lazy_ptr) ld: symbol(s) not found collect2: ld returned 1 exit status
the source code both is:
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(){} };
i thought namespace issue , try calling
analyzer::simpleanalyzer *sanalyzer = new analyzer::simpleanalyzer();
but problem remain.
suggestions? thank you
this on mac, i'm guessing? i'm not familiar compiling on mac.
can tell how you're compiling (i.e. compile flags, etc). , perhaps add example compilable).
also, can compile code using environment?
#include "clucene.h" int main(){ lucene::analysis::simpleanalyzer *sanalyzer = new lucene::analysis::simpleanalyzer(); }
i compiled above code following command no problems. (-fpic because i'm on 64 bit machine).
g++ test.cpp -lclucene -i/usr/lib -fpic
Comments
Post a Comment