Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Copying .dlls into target directory
Forum Updated to NodeBB v4.3 + New Features

Copying .dlls into target directory

Scheduled Pinned Locked Moved Unsolved General and Desktop
43 Posts 7 Posters 28.2k Views 4 Watching
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by A Former User
    #1

    Hi, all -

    I'm sure this must be a dupe, but I've searched the forum and haven't found anything. The answers on Stack Exchange don't work for me, so I figured I'd better ask the experts.

    I'm building a small app using Creator and MinGW. There are a handful of .dlls that the app needs, and I'd like to copy them to the target directory (for ease of making an installation package). Can someone please tell me how this is done?

    Using Creator 4.1 with the included MinGW package, on Windows 7.

    Thanks...

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      Some clarifications first:

      1. Do you mean Qt DLLs, or 3rd-party DLLs, or both?
      2. Which answers from Stack Exchange have you tried? (So that you don't get answers telling you to do something you've already done)
      3. Are you able to run your app properly from within Qt Creator?

      Anyway, as a starting point, have a look at windeployqt: http://doc.qt.io/qt-5/windows-deployment.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      1
      • mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        Hi, JKSH -

        1. I mean third-party libraries. These are to be found in the MinGW directory tree.
        2. here are a few answers:
          other answers
          the first suggestion is more complicated than I want to try, and the second answer doesn't work because it says that the extra_libs.path path isn't defined. (Do I need to define DESTDIR myself? I thought it was a built-in variable.
        3. yes.

        Thank you.

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          The answers in your link were complicated because the asker wanted everything done automatically. This is not strictly necessary (but it does save you a minute or so each time you want to deploy)

          From the Windows command line, do this:

          1. Navigate to the folder which contains your Qt DLLs
          2. Add the MinGW directory to your PATH
          3. Run the deployment tool, tell it where to find your built executable (see http://doc.qt.io/qt-5/windows-deployment.html)

          Example: (Assumes that you installed Qt into C:\Qt, that you're using Qt 5.6.2,, and that you have compiled your app into D:\Projects\MyApp\build-MyApp-Desktop_Qt_5_6_2_MinGW_32bit-Release\release)

          > cd C:\Qt\5.6\mingw49_32\bin
          > set path=%path%;C:\Qt\Tools\mingw492_32\bin
          > windeployqt.exe D:\Projects\MyApp\build-MyApp-Desktop_Qt_5_6_2_MinGW_32bit-Release\release
          

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          4
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            as an altrenative, in your .pro file just add to INSTALLS the libraries you want and calling make install will copy them over

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            1
            • mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #6

              Thank you both.

              I think I prefer the solution proposed by VRonin, mainly because I understand it better. Unfortunately, I'm getting this error when I try to build:

              :-1: warning: C:/Qt/5.7/mingw53_32/bin\libgcc_s_dw2-1.dll.path is not defined: install target not created

              The path is definitely there, and the file exists. What am I doing wrong?

              Thanks...

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #7

                Could you post the content of the pro file?

                Maybe just running qmake again is enough to fix this problem

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                0
                • mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #8

                  Hi, Vronin -

                  I fixed that problem by following the syntax used in the examples I posted above (with the .path and the .files).

                  Now I get no errors, but the file still doesn't move to the target directory (in this case, the debug directory).

                  .pro file:

                  TEMPLATE = app
                  CONFIG += CONSOLE
                  CONFIG -= qt
                  TARGET = storefile
                  SOURCES += \
                  	storefile_client.cpp
                  
                  #win32:QMAKE_CXXFLAGS += /MD
                  
                  HEADERS += \
                  	storefile_client.h \
                  
                  win32:LIBS += "C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\ws2_32.lib"
                  
                  INCLUDEPATH += "../ARM/inc/"
                  
                  win32 {
                      libsto_copy.files += $$QMAKE_LIBDIR_QT/libgcc_s_dw2-1.dll
                  }
                  libs_to_copy.path = $$OUT_PWD/$$OUTDIR
                  INSTALLS += libs_to_copy
                  #INSTALLS += $$[QT_INSTALL_BINS]\libgcc_s_dw2-1.dll
                  #INSTALLS += C:\Qt\5.7\mingw53_32\bin\libgcc_s_dw2-1.dll
                  
                  

                  Thank you.

                  1 Reply Last reply
                  0
                  • mzimmersM Offline
                    mzimmersM Offline
                    mzimmers
                    wrote on last edited by
                    #9

                    fixed the typo; still doesn't work:

                    TEMPLATE = app
                    CONFIG += CONSOLE
                    CONFIG -= qt
                    TARGET = storefile
                    SOURCES += \
                    	storefile_client.cpp
                    
                    #win32:QMAKE_CXXFLAGS += /MD
                    
                    HEADERS += \
                    	storefile_client.h \
                    
                    win32:LIBS += "C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\ws2_32.lib"
                    
                    INCLUDEPATH += "../ARM/inc/"
                    
                    libs_to_copy.files = $$QMAKE_LIBDIR_QT/libgcc_s_dw2-1.dll
                    libs_to_copy.path = $$OUT_PWD/$$OUTDIR
                    INSTALLS += libs_to_copy
                    #INSTALLS += $$[QT_INSTALL_BINS]\libgcc_s_dw2-1.dll
                    #INSTALLS += C:\Qt\5.7\mingw53_32\bin\libgcc_s_dw2-1.dll
                    

                    Oddly enough, it's copying the .o file, but not the .dll I want.

                    1 Reply Last reply
                    0
                    • mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #10

                      Hi
                      Im wondering if mixing

                      / and  \ is ok?
                       C:/Qt/5.7/mingw53_32/bin\libgcc_s_dw2-1.dll. 
                                               ^
                      
                      mzimmersM 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        Hi
                        Im wondering if mixing

                        / and  \ is ok?
                         C:/Qt/5.7/mingw53_32/bin\libgcc_s_dw2-1.dll. 
                                                 ^
                        
                        mzimmersM Offline
                        mzimmersM Offline
                        mzimmers
                        wrote on last edited by
                        #11

                        @mrjj said in copying .dlls into target directory:

                        Hi
                        Im wondering if mixing

                        / and  \ is ok?
                         C:/Qt/5.7/mingw53_32/bin\libgcc_s_dw2-1.dll. 
                                                 ^
                        

                        Good question. In my hard-coded tests, I tried it with all "/" and all "" and get the same error, though.

                        Does qmake have some kind of echo function where I can output the value of variables?

                        Thanks.

                        1 Reply Last reply
                        0
                        • mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Ok, was just a thought.
                          You can outout with

                          message($$VAR)

                          1 Reply Last reply
                          0
                          • mzimmersM Offline
                            mzimmersM Offline
                            mzimmers
                            wrote on last edited by mzimmers
                            #13

                            Well, I'm still stuck on this. The problem appears to be in this area:

                            DESTDIR = $$(OUT_PWD)
                            extra_libs.files = MY_LIB_FILES
                            extra_libs.path = $$(DESTDIR)
                            
                            ## Tell qmake to add the moving of them to the 'install' target
                            INSTALLS += extra_libs
                            

                            I get this error (warning):

                            :-1: warning: extra_libs.path is not defined: install target not created

                            OUT_PWD appears to be OK. I don't really know what I'm doing with the variable "extra_lib" as that was just yanked from an example above. I assumed the .files and .path were properties of the variable, but now I'm questioning what I'm doing.

                            Anyone able to shed some light onto this?

                            Thanks.

                            UPDATE:

                            I just clicked on the "see more replies" part of the answer I was trying to copy -- someone claims that INSTALLS doesn't work on Windows. Can anyone confirm or deny this? I don't find anything about this limitation in the docs. I tried invoking the make from the command line, and got this:

                            C:\Qt\Tools\mingw530_32\bin>.\mingw32-make.exe install
                            mingw32-make: *** No rule to make target 'install'.  Stop.
                            

                            So I guess it is true...?

                            1 Reply Last reply
                            0
                            • JKSHJ Offline
                              JKSHJ Offline
                              JKSH
                              Moderators
                              wrote on last edited by
                              #14

                              Try using hard-coded paths first and see if you can get that to work. After you succeed, replace the hard-coded paths with variables.

                              (I haven't used INSTALLS before and don't currently have access to a computer to try it myself)

                              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                              1 Reply Last reply
                              0
                              • mzimmersM Offline
                                mzimmersM Offline
                                mzimmers
                                wrote on last edited by
                                #15

                                Now using:

                                C:\Qt\5.7\mingw53_32\bin
                                

                                Same results.

                                1 Reply Last reply
                                0
                                • mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  well I was under the impression that make install was a unix thing as doc mentioned but
                                  then i read that mingw-make does have "install". I have however never tried it.

                                  But the plugandpaint example has

                                  target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint
                                  INSTALLS += target
                                  which maps to
                                  C:/Qt/Examples/Qt-5.7/widgets/tools/plugandpaint
                                  But nothing is copied there so Im not sure it does work.

                                  kshegunovK 1 Reply Last reply
                                  0
                                  • mrjjM mrjj

                                    well I was under the impression that make install was a unix thing as doc mentioned but
                                    then i read that mingw-make does have "install". I have however never tried it.

                                    But the plugandpaint example has

                                    target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint
                                    INSTALLS += target
                                    which maps to
                                    C:/Qt/Examples/Qt-5.7/widgets/tools/plugandpaint
                                    But nothing is copied there so Im not sure it does work.

                                    kshegunovK Offline
                                    kshegunovK Offline
                                    kshegunov
                                    Moderators
                                    wrote on last edited by
                                    #17

                                    @mrjj said in copying .dlls into target directory:

                                    well I was under the impression that make install was a unix thing as doc mentioned but

                                    No, it's a make thing. Any self-respecting make implementation (including MS's nmake) should provide the install target out of the box. :)

                                    But the plugandpaint example has

                                    Well, how did you install? Did you call make install (or equivalent) from the Qt source's base path? If not, you've erred, because there's a chain of pro files (and mkspecs and other goodies that get included and ultimately the QT_INSTALL_EXAMPLES is set for you). But anyway, that's another matter altogether.

                                    @mzimmers

                                    I suggest you run qmake manually with -d or -d -d to get some debug info back. It is possible that the qmake's makefile generator doesn't respect the INSTALLS variable (although I see no reason it shouldn't).

                                    Kind regards.

                                    Read and abide by the Qt Code of Conduct

                                    1 Reply Last reply
                                    2
                                    • mzimmersM Offline
                                      mzimmersM Offline
                                      mzimmers
                                      wrote on last edited by
                                      #18

                                      @kshegunov - thank you for the suggestion. I tried this and got ~6700 error messages; I'm not sure I did it correctly.

                                      I do have another question: my build steps are to run make first, then qmake. If qmake is a "meta-make" tool, shouldn't the order be 1) qmake and 2) make?

                                      Thank you.

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • mzimmersM mzimmers

                                        @kshegunov - thank you for the suggestion. I tried this and got ~6700 error messages; I'm not sure I did it correctly.

                                        I do have another question: my build steps are to run make first, then qmake. If qmake is a "meta-make" tool, shouldn't the order be 1) qmake and 2) make?

                                        Thank you.

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #19

                                        @mzimmers Yes qmake should be the first one

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        2
                                        • mzimmersM Offline
                                          mzimmersM Offline
                                          mzimmers
                                          wrote on last edited by kshegunov
                                          #20

                                          Well, somehow they got switched (I probably fat-fingered it). I put them in the correct order (qmake, make, make install) and still it doesn't copy the files. Here's the compiler output:

                                          08:42:17: Running steps for project storefile_client...
                                          08:42:17: Configuration unchanged, skipping qmake step.
                                          08:42:17: Starting: "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" 
                                          C:/Qt/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug
                                          mingw32-make[1]: Entering directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug'
                                          g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -I..\storefile_client -I. -I..\ARM\inc -IC:\Qt\5.7\mingw53_32\mkspecs\win32-g++  -o debug\storefile_client.o ..\storefile_client\storefile_client.cpp
                                          g++ -Wl,-subsystem,console -mthreads -o debug\storefile.exe debug/storefile_client.o  "C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\ws2_32.lib" 
                                          mingw32-make[1]: Leaving directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug'
                                          08:42:18: The process "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" exited normally.
                                          08:42:18: Starting: "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" install
                                          C:/Qt/Tools/mingw530_32/bin/mingw32-make -f Makefile.Debug install
                                          mingw32-make[1]: Entering directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug'
                                          **mingw32-make[1]: Nothing to be done for 'install'.**
                                          mingw32-make[1]: Leaving directory 'C:/Users/mzimmers/Wideband/Peninsula/build-storefile_client-Desktop_Qt_5_7_0_MinGW_32bit-Debug'
                                          08:42:19: The process "C:\Qt\Tools\mingw530_32\bin\mingw32-make.exe" exited normally.
                                          08:42:19: Elapsed time: 00:02.
                                          

                                          To my layman eyes, it's looking more like the make that comes with mingw doesn't honor installs?

                                          kshegunovK 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