PDA

View Full Version : sqlite3 with QT



vinithr
31st July 2012, 10:21
Hi all,

I have a small doubt.

I am trying to implement sqlite3 read operation in QT.The other daemon which is implemented in c will write in to database.In QT i need to read the database and show in appropriate table widget.When i trying to port read operation into QT it gives an error undefined reference to sqlite3_open_v2.

I am using same header for implementing QT.


Could anyone help me out to sort this problem. and i would like to know that whether i am going in a right path?

Thanks in advance.

Regards
Vinithr

vinithr
1st August 2012, 10:12
Hi,
I am halfway through this problem. In this i need to link a library named libsqlite3.so to Qt application. this library is located in /usr/lib/

Normally we use to link library in C/C++ using the command gcc sample.c -l /usr/lib/libsqlite3.so

I have a small query,how can i link this library in QT ?

Thanks in advance.

Regards.
Vinithr

yeye_olive
1st August 2012, 10:22
The solution does not depend on your use of Qt. It depends on which build system you use. If you use qmake, then you will need the LIBS variable (http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#libs).

vinithr
1st August 2012, 11:42
Hi,

Thanks for your reply. I am using qmake only.so i can add LIBS variable in .pro file right.?

yeye_olive
1st August 2012, 12:58
Yes, all you have to do is add a suitable line LIBS += ... to the .pro file. Refer to the link in my previous post -- and more generally to qmake's documentation -- for details. I suspect that LIBS += -lsqlite3 will be enough since the library seems to be located in a standard location on your system.

ChrisW67
2nd August 2012, 06:33
As usual it is in the docs: Declaring Other Libraries

Is there a reason you cannot use the Qt SQL support to achieve what you want?

vinithr
5th August 2012, 13:25
Thanks for your reply. I could be able to compile the code.Some customization are going on. I will get back to you,if i am getting any error.

Thanks
Vinithr