How to use "QDbf" under Windows?
-
Hey guys,
I have to read out a .dbf-file (I know, it's very old, but the files are still used in this case and my App has to import them).
Via google, I have found the Library "QDbf" ([url]http://code.google.com/p/qdbf/[/url]) and tested it under Mac OS X and everything works perfect.
Then, I tried to compile it under Windows (7) with MinGW, because the App will be mainly used under Windows. But I get lots of Warnings and a strange Error:
[CODE]definition of static data member 'QDbf::QDbfTableModel::staticMetaObjectExtraData' of dllimport'd class[/CODE]
in "moc_dbftablemodel.cpp".My example-Code, I tried to compile is:
[CODE]#include "qdbftable.h"
#include "qdbfrecord.h"
#include <QtGui>int main(int argv, char **args)
{QApplication app(argv, args);
QTextEdit textEdit;
textEdit.show();QDbf::QDbfTable table;
if (!table.open("datei.dbf")) {
qDebug() << "file open error";}
QString output;
while (table.next()) {
QDbf::QDbfRecord record = table.record(); for (int i = 0; i < record.count(); ++i) { if(!(record.value(i).toString().trimmed()=="")) { if(record.fieldName(i)=="NAME") { output.append(record.fieldName(i)); output.append(QLatin1String(": ")); output.append(record.value(i).toString().trimmed()); output.append(QLatin1String("; \n")); } if(record.fieldName(i)=="PRENAME") { output.append(record.fieldName(i)); output.append(QLatin1String(": ")); output.append(record.value(i).toString().trimmed()); output.append(QLatin1String("; \r \n")); } } } qDebug() << output;
}
table.close();
textEdit.setText(output);return app.exec();
}[/CODE]
The Header/Source-Files are in the same directory with the main.cpp.
And now my Questions:
- How do I import a class correctly in my Qt environment? Have the Lib to be integrated, or is it enough to copy it in the Dir with my other sourcefiles?
- Can I import it as a .dll? Because the Example in the QDbf-Package compiles correctly under Windows/MinGw and creates a .dll and .a-File. When I include it via "LIBS += ..." in my .pro-file, nothing happens. How do I include it correctly and use the functions of the dll in my Code?
Hope you can help me getting this to run! ;)
Greetings, Julian
-
Hi,
You don't need to copy anything.
@
INCLUDEPATH += C:/PATH_TO_QDBF_INCLUDE_FILES
LIBS +=
-LC:/PATH_TO_QDBF_DLL \ #<- This one without spaces would be best
-lqdbf # have the correction name for debug/release builds
@
And you should be good.Hope it helps
[edit, code added]
-
FUCK YEAH, it WORKS! :D
Thank you very much!!!But I had to avoid relative paths, only the absolute "C:/..." worked for me.
-
I also prefer to use full paths, in that case I know exactly where the linker will look for the libs.