Results 1 to 6 of 6

Thread: Deploying App on Linux

  1. #1
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Deploying App on Linux

    hi,

    I have written an App (Qt4.3.4, Eclipse) on Windows that uses the sqlitedriver as plugin. But I build the driver with the latest sqlite version (3.5.8). Everything works fine on Windows. My Question is what the best Option on Linux is. It seems I can not just put the driverplugin in the app/sqldrivers/ path. If their is an old version of sqlite on the system the App loads that system driver or the plugin that was build with qt-source (which is an old version as well).
    Is their a way to force the App to load the plugin that comes with the App on Linux?
    I am sorry, my knowledge about Linux is very limited. I learned from several websites that I could build it in static mode for Linux to avoid that. But I also would like to extend my App with own addidional plugins (using the pluginloader) to add more features. But if I build it in static mode I can nor use this approach!? Thats what i read in the documentation.
    Could anyone give me an advice how to solve this dilemma.
    thx in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Deploying App on Linux

    Quote Originally Posted by janus View Post
    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).

    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.

  3. #3
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: Deploying App on Linux

    I tried so solve the problem by using cmake. I made a little example:

    main.cpp
    Qt Code:
    1. #include <QtCore>
    2. #include <QCoreApplication>
    3. #include <QDebug>
    4. #include <QSqlDatabase>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QCoreApplication a(argc, argv);
    9.  
    10. qDebug() << QSqlDatabase::drivers();
    11.  
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    CMakeLists.txt
    The first part is from the QtCentre cmake Tutorial. The second part from www.cmake.org/Wiki

    Qt Code:
    1. PROJECT( SQLITE_RPATH )
    2.  
    3. # with SET() command you can change variables or define new ones
    4. # here we define SAMPLE_SRCS variable that contains a list of all .cpp files
    5. # note that we don't need \ at the end of line
    6. SET( SQLITE_RPATH_SRCS
    7. ./main.cpp )
    8.  
    9. # enable warnings
    10. ADD_DEFINITIONS( -Wall )
    11.  
    12. # by default only QtCore and QtGui modules are enabled
    13. # other modules must be enabled like this:
    14. SET( QT_USE_QTSQL TRUE )
    15.  
    16. # this command finds Qt4 libraries and sets all required variables
    17. # note that it's Qt4, not QT4 or qt4
    18. FIND_PACKAGE( Qt4 REQUIRED )
    19.  
    20. # add some useful macros and variables
    21. # (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script)
    22. INCLUDE( ${QT_USE_FILE} )
    23.  
    24. # and finally this will run moc:
    25. QT4_WRAP_CPP( SQLITE_RPATH_MOC_SRCS ${SQLITE_RPATH_MOC_HDRS} )
    26.  
    27. # we need this to be able to include headers produced by uic in our code
    28. # (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
    29. INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
    30.  
    31. # here we instruct CMake to build "sample" executable from all of the source files
    32. ADD_EXECUTABLE( SQLITE_RPATH ${SQLITE_RPATH_SRCS} ${SQLITE_RPATH_MOC_SRCS} )
    33.  
    34. # last thing we have to do is to tell CMake what libraries our executable needs,
    35. # luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us:
    36. TARGET_LINK_LIBRARIES( SQLITE_RPATH ${QT_LIBRARIES} )
    37.  
    38. #-------------------------------------------------------------------------------
    39.  
    40. # skip the full RPATH for the build tree
    41. SET(CMAKE_SKIP_BUILD_RPATH TRUE)
    42.  
    43. # when building, use the install RPATH already
    44. # (so it doesn't need to relink when installing)
    45. SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
    46.  
    47. # the RPATH to be used when installing
    48. SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
    49.  
    50. # add the automatically determined parts of the RPATH
    51. # which point to directories outside the build tree to the install RPATH
    52. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
    53.  
    54. #--------------------------------------------------------------------------------
    55.  
    56. MESSAGE(STATUS "CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}")
    57.  
    58. INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SQLITE_RPATH
    59. DESTINATION ${CMAKE_INSTALL_PREFIX})
    To copy to clipboard, switch view to plain text mode 

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

  5. The following user says thank you to wysota for this useful post:

    janus (6th May 2008)

  6. #5
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default 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

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

Similar Threads

  1. QPalette works differently on windows and linux
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 6th March 2008, 07:27
  2. Replies: 19
    Last Post: 21st January 2008, 09:13
  3. Opacity in Linux OS
    By shyam prasad in forum Qt Programming
    Replies: 2
    Last Post: 22nd May 2007, 05:59
  4. QT 3 (linux) to 4(windows XP)
    By deekayt in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2006, 18:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.