Results 1 to 2 of 2

Thread: qmake: copy qt dlls to output directory

  1. #1
    Join Date
    Apr 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default qmake: copy qt dlls to output directory

    I googled this question but didn't find any working solution.

    Eventually I decided to ask it once again.

    Can anybody provide me with a WORKING example of pro-file that copies qt dlls into output directory?

    I tried this:
    Qt Code:
    1. CONFIG += qt release
    2. SOURCES += src/main.cpp
    3.  
    4. message($(QTDIR)) # output: c:\Qt\4.8.4_vs2008\
    5.  
    6. # Method 1
    7. qt_libs.path=release
    8. qt_libs.files=$(QTDIR)bin/QtCore4.dll
    9. INSTALLS += qt_libs
    10.  
    11. # Method 2
    12. EXTRA_BINFILES += $(QTDIR)bin/QtCore4.dll
    13. EXTRA_OUT_FILES += release
    14. for(FILE,EXTRA_BINFILES){
    15. QMAKE_POST_LINK += $$quote(cp $${FILE} $$EXTRA_OUT_FILES $$escape_expand(\\n\\t))
    16. }
    To copy to clipboard, switch view to plain text mode 

    But it also doesn't work.
    $(QTDIR) suddenly becomes empty. Although message($(QTDIR)) above produces a valid path to qt installations.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: qmake: copy qt dlls to output directory

    Have you tried using "$$(QTDIR)" (note the double dollar) at line 8? This should embed the value of the QTDIR environment variable into the Makefile rather than looking for the value at the time you run the Makefile.

    Your second option won't work on a Windows machine because "cp" is a UNIX copy command.

    This approach works on Linux without relying on an external QTDIR variable, and should also do so on Windows with appropriate name changes:
    Qt Code:
    1. qtlibs.path = release
    2. qtlibs.files += $$[QT_INSTALL_LIBS]/libQtCore.so
    3. qtlibs.files += $$[QT_INSTALL_LIBS]/libQtGui.so
    4. INSTALLS += qtlibs
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 27th December 2012, 06:01
  2. Problem with Copy a directory using pro & qmake
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 10th December 2012, 10:40
  3. Replies: 5
    Last Post: 22nd November 2012, 03:46
  4. Replies: 8
    Last Post: 23rd March 2011, 10:13
  5. Replies: 4
    Last Post: 24th February 2006, 10:30

Tags for this Thread

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.