Important: Please read the Qt Code of Conduct -

Copying external dlls to destination directory

  • I want to copy external libraries dlls to the destination dir i.e debug/release folder through qmake in the .pro file. I have those dlls in "C:\Program Files\MyLib".

    I have the following code :

    // deploy location within the project dir.
    DESTDIR = $$deploy_loc/release

    // MYLIB_HOME = C:\Program Files\MyLib
    copyQtdata.commands += $(COPY_DIR) /f $$shell_path($$(MYLIB_HOME)\bin\mylib.dll) $$shell_path($$DESTDIR)

    Since MYLIB_HOME expands to the above path with space, xcopy gives me an error "Invalid number of arguments" because tof the space.

    The above copyQtData.commands expands to below while building:

    xcopy /s /q /y /i /f C:\Program Files\MyLib\bin\mylib.dll D:\GithubSource\MyProject\Deploy\bin\release.

    Please guide me.

  • @Uday-More

    Put your path in quotes.
    "C:\Program Files\.....\"

  • @Uday-More said in Copying external dlls to destination directory:

    copyQtdata.commands += $(COPY_DIR) /f $$shell_path($$(MYLIB_HOME)\bin\mylib.dll) $$shell_path($$DESTDIR)

    The command has to be changed to

    copyQtdata.commands += $(COPY_DIR) /f $$shell_quote($$(MYLIB_HOME)\bin\mylib.dll) $$shell_path($$DESTDIR)

    Note : shell_path has been changed to shell_quote.

    It works.

Log in to reply