I have a program which uses QTDS driver.
in development environment everything workds fine. in production i have both the TDS plugin and sybdb available with appropriate rights.
they are both inside a directory which has been added to the LD_LIBRARY_PATH
and yet i got
QSqlDatabase: QTDS driver not loaded
EDIT I aslo can tell that:
app.libraryPaths()
points to a directory in which there is an sqldrivers/ directory containing all the libs If i rename this direcotry in dev I get the same error, if I put it back it works again.
In dev it works if and only if this directory is here. In Prod it does not work in either case. While “MyappDir/” is always listed in the
app.libraryPaths()
self answer:
When a linux app loads it need to be able to access all the libXXX.so it needs. "ld" will look for them in any directory declared in the "LD_LIBRARY_PATH" variable
However Qt seems to load its plugins dynamically from some paths which can be found there:
QCoreApplication app(argc,argv);
qDebug() << app.libraryPaths();
which printed
("/my/App/Path","/Qt/Dir/Path" )
And from one of this path it should load the plugins. So if in qtDir you have
/Qt/Dir/Path/plugins/sqldrivers/libqsqltds.so
You want to make sure to deploy something like:
/my/App/Path/sqldrivers/libqsqltds.so
this worked fine because the app path is always in "app.libraryPaths()". However, where things get complicated it that libqsqltds.so requires "libsybdb.so.5" to work properly. Which I knew so there also was a
/my/App/Path/sqldrivers/libsybdb.so.5
which was wrong because Qt loads dynamically libqsqltds.so but not its dependency, which it seems ld expects to find the usual way ( e.g. in the LD_LIBRARY_PATH )
The fact is that in my dev/integration environments I had libsybdb.so.5 in my path, but not in my production environment.
So whatever Qt plugins you need make sure to copy the plugin directory ( with only the .so inside ) to your production environment. And Also make sure that performing:
ldd /my/App/Path/sqldrivers/libsybdb.so.5
will not print any "not found" as these dependency will not appear with:
ldd /my/App/Path/myAppBin