Qt6 qt_generate_deploy_app_script plugin DLL copying - qt

Currently I have to manually copy the platforms and imageformats plugin folders to the directory containing the .exe that MSVC compiled. This is very tedious as the output folders often get deleted if you're working on your CMakeLists.txt or changing compilation target.
Now qt_generate_deploy_app_script seems like an official Qt solution to solve this problem, but it does not work.
I have added the CMake bits to my CMakeLists.txt as stated
qt_generate_deploy_app_script(
TARGET HiveWE
FILENAME_VARIABLE deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
I can see some generated deploy scripts appear under build\x64-RelWithDebInfo\.qt, but they do not seem to be run as no DLL folders get copied to where my .exe is.
Am I misinterpreting what qt_generate_deploy_app_script should do or is it simply broken?

If you want to Creat exe in windows From Qt project you should use windeployqt
To Deploy and create Exe output with QT in windows you should follow this way:
put your compiler path in your system path. for example, if you use mingw81_64, you should set it. something like Qt/tools/mingw81_64/bin
copy exe file that provides after building in release mode in one
folder and run mingw81_64 cmd (it has separate cmd) and cd to that
folder path
windeployqt app.exe
you are using Cmake So first create one release output and then use step 3.
This command will get all dll needs for your app and your exe will work .
if you use qml
windeployqt --qmldir (the path of its directory ) app.exe
and also see these youtube videos for more info:
https://www.youtube.com/watch?v=LdSTgR0xJco
https://www.youtube.com/watch?v=hCXAgB6y8eA

Related

Unable to customise the build directory for Qt Creator/qmake

I've got problem trying to specify the build directory (the directory that is to store all the files prior to copying them to the DESTDIR path).
I've got the following values in my .pro file:
DESTDIR = E:/Development/project/build/core/debug
OUT_PWD = E:/Development/project/build/core/debug
OBJECTS_DIR = $$DESTDIR/.obj
MOC_DIR = $$DESTDIR/.moc
RCC_DIR = $$DESTDIR/.qrc
UI_DIR = $$DESTDIR/.ui
Now, all the files eventually end up in that location, however during build, the compiler is always using the "E:/Development/build/MinGW_32bit-Debug/src/core" folder (note the missing project path). This is annoying, because I want to use the /Project/build directory as this location (which is not tracked in my git repo).
Ideally, I'd like this path to be: E:\Development\project\build\src\core\debug.
The reason I want to do this is that the build process has the same location to include the compiled libs from (it's a subdirs project).
I've had a look in the Tools > Options > Build & Run > General settings, and the default build directory is: build/build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}
I've had a look in my project.pro.user file, and found the following line:
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/Development/build/MinGW_32bit-Debug</value>
However I'm unable to change this value. If I edit this line in the file directly, as soon as I open Qt Creator again, the change has reverted back.
Is this a Qt Creator thing, or is it a qmake thing? Would I better off using a different build system such as CMake?
The build directory is "specified" by starting qmake or cmake in the build directory. There's no point to setting it in the .pro file itself.
Qt Creator stores the build directories for a project in the .user file. Any changes made to this file outside of Qt Creator, while the project is open in the Creator, will be lost. Creator loads the file when opening the project, or creates a new one if it doesn't exist.
When the Creator starts the build by invoking qmake or cmake, it starts that process in the build directory. That's also how you should be building the project manually from the command line.
Finally, it makes very little sense to override the destinations of the intermediate build results. They are somewhere within the build directory, and that's all that matters. You're not using these files directly for anything anyway.
The customary way to build a qmake project:
mkdir project-build
cd project-build
qmake ~/project-src
make -j
The build folder should not be within the source tree!
I've recently started keeping them in $TEMP / %TEMP%: manually purging the stale builds of all sort of test projects got old after a while :)

Qt renaming path of the project

sometimes when I rename the path to a qt project, it cannot be run even though I clean qmake and rebuild it!!! the path does not contain any space. and the project is completely correct and I know that the error is for path renaming , for example when I rename :
D:/abd/projects/LAND_2/Land_QT/...
to
D:/abd/projects/LAND_2/Land2_QT_SA/...
it cannot be build and says that some include file is missing(but the file is there!).
what is the problem?
I work with dynamic qt5.2 on windows 7.
Edit:
when I copy the project folder to a new directory( a path upper than current path) then the project can be build and run.
When you rename the path to the project, go to the project folder and delete the file with .pro.user extension. Open the project and Qt will ask you to configure the project. Choose the required kit, build and run the project.It should build successfully now
If you have changed path multiple times the .pro.user file is created multiple times delete all files with this extension and compile

mt.exe in Qt StandAlone .exe

I finally built a static version of Qt 5.1.1 using microsoft visual studio. I created my .exe standalone file using this code:
qmake Hello.pro
nmake release
cd release
mt.exe -manifest Hello.exe.manifest -outputresource: Hello.exe;1
what is mt.exe and what does the last line do with the "Hello.exe" file?
You could just use CONFIG += embed_manifest_exe though, but in essence you need to put the manifest file beside your executable and the last line seems to take care of that.
That is, it is adding a manifest to your "Hello.exe" executable file.
If you do not happen to know what manifest files are, then you can read the MSDN documentation below, but in short: they are carrying run time information for your executable in this particular case:
http://msdn.microsoft.com/en-us/library/aa374191(v=vs.85).aspx

Copy file to destination directory in Qt Creator

I want to copy a data file from a directory in my source tree to the directory of the linked app so it's available at runtime, on Windows only. There appear to be two suggested techniques: use a post target dependency to issue a DOS copy command (Including resource files in Qt Creator build directory) or use an install step (Copy a file to the build directory after compiling project with Qt), but I cannot make either work in the way I would like.
The former requires me to use qmake path variables to generate my source and destination paths, but they contain backslash path separators, which the DOS copy command cannot handle.
The install solution forces other users of my project to set up a post build step in Qt Creator before it will work (one per configuration, in fact) and I would like to avoid this, as I want to make my project work with a default Qt Creator installation.
Is there any way to do this apparently simple task that can be wholly defined in the .pro file for the project? For example, is there a way to expand qmake path variables in a platform specific way?
Though these commands run ONLY after the executable is ACTUALLY linked, this solution doesn't require an external batch file. Note: this a Windows-only solution:
From our .pri file:
win32 {
...
# Copy the appropriate dll files into the target destination directory.
QMAKE_TBB_LIBDIR = $$quote($$PWD/MySource/MyLibs/$${PLATFORM_NAME}/vc9)
QMAKE_POST_LINK = copy /y $${replace(QMAKE_TBB_LIBDIR, /, \\)}\\*.dll > $${replace($$quote(DESTDIR), /, \\)}
...
}
This places a command in the Makefile that copies all the .dll files in MyLibs/x64 or MyLibs/Win32 into the destination directory.
However, if the executable did not need to be linked, then the .dlls are NOT copied.
The post build batch file would not have this limitation.

how to create .exe file for my Qt based app

i wrote a program in Qt-Creator 1.3.1 and Qt 4.6.2
and realy dont figure out how to create a simple .exe file for the program i just wrote...
i rather do it with the Qt-Creator if it's possible
In Qt Creator, when you build (Ctrl+B) your project, it always creates a .exe that is executed when you run the app from Qt Creator (Ctrl+R or the big play button).
If you want to find this .exe, you should look in the folder where your .pro (the project file) is located in the folder debug (or release depending on your build configuration).
#Live is right. See in release or debug dir. But if you move the .exe and want to execute you will get notofications about DLL's that miss. You can find them from yout Qt installation dir. Put next to your exe file all required DLL's and you're done! The DLL files will tell your your exe file while you execute it!

Resources