Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Why no libqsqlodbc.so?
Hi, I'm writing a Qt app that connects to an MS SQLServer 2005.
Currently I only really need the app to work in Windows (which works fine) but because I have this fancy blog where I document how to do Qt stuff for both Windows, Mac and Linux, I decided to try having a chat with the SQLServer from OSX or from Linux. I mean, how hard could it be?
Well two (2) nights and many cups of coffee later I got it working for OSX. Instead of that oneliner in Windows (.setDatabaseName(...) you have to build a libtdsodbc.0.so and write two files, odbc.ini and .freetds.conf. But now I can talk to the SQLServer from my Mac, yippee :-)
Then I tried Linux (Ubuntu 13.10) (it couldn't be worse than OSX I thought) when I discovered a showstopper: there's no DLL included for ODBC in Qt 5.2.1 for Linux :-( I.e. I can't find the file libqsqlodbc.so in plugins/sqldrivers.
Anyone knows why? Is it because SQLServer is not so popular in Linux or?
AFAIK, PostgreSQL and MySQL (mariaDB) are the most used servers on linux and until now I must say most of the user of ODBC I saw where on windows (not that it means they are the only one).
You could open a discussion about it on the interest mailing list
Well, agreed PostgreSQL and MyMaria are much more popular on Linux, but since Microsoft is using Qt (for example, Microsoft Remote Desktop for Mac is written in Qt) I think Qt should be nice to Microsoft and support SQL Server on Linux as well (just joking :-).
Anyway, I found Qt's interest mailing list, thanks for the pointer!
A bit more documentation about it would probably be welcome :-)
andreyc last edited by
From my observation of the Qt configuration script:
It has an option "plugin-sql-<driver>".
If odbc or iodbc is specified then the script will run the checks on unix/odbc and unix/iodbc libraries.
Hmmm, thanks I might give it a try, I learned on the Mac about unixodbc and iodbc (OSX comes with an old iodbc preinstalled, that's what I used).
On Debian/Ubuntu it's pretty easy, just apt-get iodbc and/or unixodbc.
Then on both Mac and Linux you have to get freetds running, on the Mac I had to build it myself, but on Debian/Ubuntu it's just another apt-get.
But I'm a complete noob when building Qt from the command line and all the options, it seems in this case it is not sufficient just to open the qt.pro file from QtCreator :-)
andreyc last edited by
I have built qtbase from the sources but without odbc.
It went smooth. I was using ubuntu 12.04, 14.04, fedora 20
My steps after applying all changes described in "this article":http://qt-project.org/wiki/Building_Qt_5_from_Git
tar xJf qtbase-opensource-src-5.2.1.tar.xz
./configure -prefix $prefix -nomake examples -no-rpath -opensource -confirm-license -qt-sql-sqlite -plugin-sql-sqlite -qt-libpng -qt-xcb
After that I build and installed qtdeclarative-opensource-src-5.2.1.tar.xz
But I do not use qtdeclarative in my project, so I deleted it later from my installation.
tar xJf qtdeclarative-opensource-src-5.2.1.tar.xz
Thanks for the command line stuff, if I get this work I promise I at least write about in my blog (as SGaist says above, a bit more documentation..)
BTW: totally off-topic, but I saw that option in ./configure: -no-rpath
Another hidden gem in Qt (!) very useful for an idea I have:
QtCreator should have a Build For Distribution menu command, where it creates a directory prefixed "distribution-.." instead of "build-". For Windows, it copies msvcr110.dll etc. to it, for Linux it does that -no-rpath trick and for the Mac it runs macdeployqt for you, and of course copy the needed plugin DLLs to the proper subdirectory in the distribution folder. If we had this, some of the often repeating questions on this forum would not appear so much.
(This is something I probably should post on the Qt interest mailing list.)