Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] Deploying third-party shared libraries from QtCreator on Windows

[Solved] Deploying third-party shared libraries from QtCreator on Windows

Scheduled Pinned Locked Moved Installation and Deployment
5 Posts 4 Posters 5.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dusktreader
    wrote on last edited by
    #1

    I am developing an application that has dependencies on several third-party shared libraries on windows.

    The application will also be deployed on Linux, but the typical library paths (/usr/lib, /usr/local/lib) will occomodate Linux builds very easily.

    My question is, what is the proper way to copy the third-party shared libraries into the build directory within QtCreator. I have the DESTDIR variable set (this is not a shadow build, as the path for building is explicitly defined in the .pro file), so the executables are built in an explicitly defined location. Additionally, I control where the moc and .o files are placed. I would like the final step for a build to copy the shared libraries from my project's ./thirdparty folder into the build directory, so that when I run the executable from QtCreator, it doesn't crash with a failed shared library load.

    The purpose for bundling shared object files from QtCreator is to allow other developers (with very little experience deploying shared library applications) to collaborate on this project without having to endure a lot of pain in file management. I would like QtCreator to do the work for them. This of course minimizes the chances of them screwing it up and pestering me to do these things for them.

    I have tried using the DISTFILES variable, the INSTALLS variable, as well as some other kookier things to make this happen. What is the preferred method?

    “Machines take me by surprise with great frequency.” -- Alan Mathison Turing

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on last edited by
      #2

      I usuaually just adjust the PATH variable to point to my 3rdparty folder. Otherwise you can do sth. like this:
      @
      QMAKE_POST_LINK += copy /Y $$PWD\thirdparty\* $$replace(DESTDIR,"/","\") $$escape_expand(\n\t)
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Moved to Installation & Deployment forum.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AlekseyK
          wrote on last edited by
          #4

          Yes, I use same:
          @QMAKE_POST_LINK = cp -f $$IN_PWD/lib/mylib.1.0.0.dylib $$DESTDIR@

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dusktreader
            wrote on last edited by
            #5

            Thank you for the help. I used QMAKE_PRE_LINK instead of the post-link option. Since I'm bundling the .dll's anyway, it makes sense to link against them in their new homes. Anyhow, this is how my .pro ended up looking (in part)

            @
            win32 {
            message( "linking libraries for windows" )

            LIBS += -L $$DESTDIR
            
            !exists( $$DESTDIR/glew32.dll ) {
                COPY_CMD += copy $$ROOT/thirdparty/glew/lib/glew32.dll $$DESTDIR &
            }
            LIBS += -lglew32
            
            !exists( $$DESTDIR/jpeg62.dll ) {
                COPY_CMD += copy $$ROOT/thirdparty/jpeg/lib/jpeg62.dll $$DESTDIR &
            }
            LIBS += -ljpeg62
            
            !exists( $$DESTDIR/libopencv_imgproc230.dll ) {
                COPY_CMD += copy $$ROOT/thirdparty/opencv/lib/libopencv_imgproc230.dll $$DESTDIR &
            }
            LIBS += -lopencv_imgproc230
            
            !exists( $$DESTDIR/libopencv_core230.dll ) {
                COPY_CMD += copy $$ROOT/thirdparty/opencv/lib/libopencv_core230.dll $$DESTDIR &
            }
            LIBS += -lopencv_core230
            
            COPY_CMD  = $$replace( COPY_CMD, "/", "\\" ) $$escape_expand( \\n\\t )
            
            QMAKE_PRE_LINK += $$COPY_CMD
            

            }
            @

            This works very well for me. Thanks again!

            “Machines take me by surprise with great frequency.” -- Alan Mathison Turing

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved