Re: Deploying App on Linux
Quote:
Originally Posted by
janus
Is their a way to force the App to load the plugin that comes with the App on Linux?
You can make sure the proper version of the library is earlier than the other in the library search path by putting its directory path in the LD_LIBRARY_PATH environment variable. An alternative would be to force the linker to load the library from a predetermined path by using the "rpath" option of the compiler (google for more info).
Quote:
But if I build it in static mode I can nor use this approach!? Thats what i read in the documentation.
Yes, that's correct.
Re: Deploying App on Linux
I tried so solve the problem by using cmake. I made a little example:
main.cpp
Code:
#include <QtCore>
#include <QCoreApplication>
#include <QDebug>
#include <QSqlDatabase>
int main(int argc, char *argv[])
{
return a.exec();
}
CMakeLists.txt
The first part is from the QtCentre cmake Tutorial. The second part from www.cmake.org/Wiki
Code:
PROJECT( SQLITE_RPATH )
# with SET() command you can change variables or define new ones
# here we define SAMPLE_SRCS variable that contains a list of all .cpp files
# note that we don't need \ at the end of line
SET( SQLITE_RPATH_SRCS
./main.cpp )
# enable warnings
ADD_DEFINITIONS( -Wall )
# by default only QtCore and QtGui modules are enabled
# other modules must be enabled like this:
SET( QT_USE_QTSQL TRUE )
# this command finds Qt4 libraries and sets all required variables
# note that it's Qt4, not QT4 or qt4
FIND_PACKAGE( Qt4 REQUIRED )
# add some useful macros and variables
# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script)
INCLUDE( ${QT_USE_FILE} )
# and finally this will run moc:
QT4_WRAP_CPP( SQLITE_RPATH_MOC_SRCS ${SQLITE_RPATH_MOC_HDRS} )
# we need this to be able to include headers produced by uic in our code
# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
# here we instruct CMake to build "sample" executable from all of the source files
ADD_EXECUTABLE( SQLITE_RPATH ${SQLITE_RPATH_SRCS} ${SQLITE_RPATH_MOC_SRCS} )
# last thing we have to do is to tell CMake what libraries our executable needs,
# luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us:
TARGET_LINK_LIBRARIES( SQLITE_RPATH ${QT_LIBRARIES} )
#-------------------------------------------------------------------------------
# skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
# when building, use the install RPATH already
# (so it doesn't need to relink when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# the RPATH to be used when installing
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#--------------------------------------------------------------------------------
MESSAGE(STATUS "CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}")
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SQLITE_RPATH
DESTINATION ${CMAKE_INSTALL_PREFIX})
The executable is installed in usr/local and the driver is in /usr/local/lib .
But the executable does not find the driver in /usr/local/lib . If their is one, it loads the driver from the Qt Path ... any idea?
Re: Deploying App on Linux
Plugins have to be in well defined paths and the compilation process has nothing to do with it. Take a look at QCoreApplication::addLibraryPath() and plugins documentation as well as our FAQ section about plugins.
Re: Deploying App on Linux
hm, but then I dont understand your previous post, Anyway, thanx . I think I can solve this issue with qt.conf
Re: Deploying App on Linux
Earlier I didn't understand what you mean but your previous post clarified the situation. At least I think so.