Qt World Summit: Register Today!

Loading dynamic library issue

  • Hi All,

    I have one dynamic library as we are loading at run time from code so we have common code that are working on both windows and linux.

    In windows name of librayr is library.dll and for linux it is liblibrary.so file. If i want to load the library and put the code common then is there any functionality in Qt that will internally take care of architecture ?

    I don't want to put the ifdef macro for architecture

    Please let me know how can i do through common code for windows and linux for loading the dynamic library ?


  • So does this library have different api depending on linux or windows?
    if not you can tell it in .pro file to use the particular file...
    Something like
    win32 {
    unix {
    in your pro file

  • I don't want to add in .pro file.
    Is there any common method in Qt that will load both the .dll and .so file i don't want to give extension while giving the library name so implementation will remain common.

    Please suggest.

  • "QLibrary":http://qt-project.org/doc/qt-4.8/qlibrary.html takes care of that for you, you only need to load "library" and Qt will add the platform-specific parts of the file name for you.

  • No, there is no way to use the same library on windows and linux. You can use the same source code and build two libraries (one for linux, one for windows).

Log in to reply