Hey there, i've seen that theres a libQtCLucene4.a library in the lib folder and there's also a CLucene folder inside /src/3rdparty/clucene/src/

Since i wasnt able to compile clucene on windows, i thought about giving this a try. I made a simple main that indexes to files, adding the necesary includepaths and defining _BUILD_FOR_QT_ to avoid looking for the clucene-config.h file.

It compiled fine, but when trying to link it throws undefined references to every CLucene class, and also inside clucene classes it throws an error "vtable for lucene::analysis::WhitespaceAnalyzer". Has Any one used this libraries and headers?

heres my pro file, and my simple main.cpp

testQtLucene.pro:
Qt Code:
  1. QT += core
  2.  
  3. QT -= gui
  4.  
  5. TARGET = testQtLucene
  6. CONFIG += console
  7. CONFIG -= app_bundle
  8.  
  9. TEMPLATE = app
  10.  
  11. INCLUDEPATH += C:\Qt\4.7.4\src\3rdparty\clucene\src C:\Qt\4.7.4\src\3rdparty\clucene\src\CLucene C:\Qt\4.7.4\tools\assistant\lib
  12.  
  13. SOURCES += main.cpp
  14.  
  15. LIBS += -lQtCLucene4
  16.  
  17. DEFINES += _BUILD_FOR_QT_
To copy to clipboard, switch view to plain text mode 

main.cpp:
Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include "CLucene.h"
  3. #include "CLucene/CLConfig.h"
  4. #include <QFileInfo>
  5.  
  6. using namespace lucene::index;
  7. using namespace lucene::analysis;
  8. using namespace lucene::util;
  9. using namespace lucene::store;
  10. using namespace lucene::document;
  11.  
  12. int main(int argc, char *argv[])
  13. {
  14. WhitespaceAnalyzer an;
  15. IndexWriter *writer = new IndexWriter("luceneIndex", &an, true);
  16.  
  17. QFile file("test1.txt");
  18. file.open(QIODevice::ReadWrite);
  19. QString content(file.readAll());
  20. file.close();
  21.  
  22. Document doc;
  23. doc.add(*new Field(_T("path"), QFileInfo("test1.txt").absolutePath().toStdWString().c_str(), Field::STORE_YES | Field::INDEX_UNTOKENIZED));
  24. doc.add(*new Field(_T("contents"), content.toStdWString().c_str() , Field::STORE_YES | Field::INDEX_TOKENIZED));
  25.  
  26. writer->addDocument( &doc );
  27.  
  28. file.setFileName("test2.txt");
  29. file.open(QIODevice::ReadWrite);
  30. content = QString(file.readAll());
  31. file.close();
  32.  
  33. doc.clear();
  34. doc.add(*new Field(_T("path"), QFileInfo("test2.txt").absolutePath().toStdWString().c_str(), Field::STORE_YES | Field::INDEX_UNTOKENIZED));
  35. doc.add(*new Field(_T("contents"), content.toStdWString().c_str() , Field::STORE_YES | Field::INDEX_TOKENIZED));
  36.  
  37. writer->addDocument( &doc );
  38.  
  39. return 0;
  40. }
To copy to clipboard, switch view to plain text mode