Qmake does not support build directories below the source directory - qt

I have created an application that compiles and runs like a charm on OS-X. I would now like to start getting it to work on Windows. To start, I copied the project to a windows machine and just tried to compile, but got this error:
:: warning: Qmake does not support build directories below the source directory.
Any ideas?

Set the shadow build directory to some folder on the same level of your project directory:
folder/
project/
project-shadow-build-release/
project-shadow-build-debug/
You can do this in the "Projects" view, via the toolbar on the left. To me, this warning was just an annoyance, a project never failed to build because of it.

Don't copy your project.pro.user file when you are copying a project from one machine to another, or from one directory to another. When you open the project, Qt Creator will offer to create a new build directory in the proper place.

Andref gave the correct answer to resolve this warning, but you may want to understand why this requirement exists.
In fact, the build directory must be at the same folder level as the project (i.e. it can't be above or below). The reason why is that the linker is called from the build directory. Hence, any relative paths to library files will be different than what you entered in your project file.
It kinda sucks. I like to put all intermediate files in their own folder. But you simply can't with qmake.

.pro.user are generated files by Qt Creator. They are unrelated to qmake and should not be touched (and not put into a VCS for that matter)

Just remove the files with the pro.user extension , worked for me

I also got this, trying to compile a project created on linux.
Another way to solve it is to change the paths in the .pro.user file (in the directory of your project)

Right Click on a project: Set As Active Project
Click on the Projects button (The one with the spanner image)
Edit build configuration : Debug / Profile / Release / and change the default directories, OR just uncheck the Shadow build check box.
The Build directory path should now change to black, from red

Related

Qt6 qt_generate_deploy_app_script plugin DLL copying

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

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

Change source directory and working directory depending on release type

I am using Qt and from reading other questions on here such as: How to specify different Debug/Release output directories in QMake .pro file I have been able to change where the build files go.
Is it correct here that you have to manually edit the .pro file and also I cannot see a way to change the working directory that is used on the different releases.
I look on the Projects tab and there is a Run settings but the working directory on here is the same for both debug and release configurations. Is there a way to change this?
Yes, you have to edit the .pro file to change the directories where the build files go. (C'mon, it's not that much work!) :-)
If you enable the "shadow build" option, your working directory will automatically change as you go between debug and release builds.

moving Qt directory

I'm working on a Qt4.7.3 project on mac osX (with xCode). I would like to move my Qt directory (installed with Qt installer). The problem is that some Qt executable files have hardcoded paths. I've already recompiled Qmake specifying the new Qt directory. So the project now compile and link perfectly, but at run time it cannot find the qt libraries (it still look into my old Qt directory). Is there other harcoded path somewhere, other configuration files to edit?
By the way, the reason why I want to move my Qt directory is to allow to share qt files via revision control tool.
The pre-built installer actually puts all the framework files into the system location (/Library/Framworks/) and you will have a hard time moving those.
Your best bet is to build it from source and specify a different install location. ./configure -help will show you how. (Use the -prefix option)
Hard links could be a way to go in this kind of situation I guess.
Try this.
Create qt.conf file in the same folder as your qmake.exe file.
[Paths]
Prefix = E:/Qt/4.8.3
Follow this link for detail description.
http://richardt.name/blog/moving-a-qt-installation-directory/

Missing file [Qt]

I'm successfully going through proccess of building an application in Qt but when I try to run .exe file by double clicking on it (outside of qt) I'm getting an error saying:
"The program can't start because mingwm10.dll is missing from your computer. Try reinstalling the program to fix this problem."
I checked for this file and I found it, so I think there is some path to be set in qt, but I don't know neither where and how to do it. Could anyone explain to me how to do it?
Thank you.
I think you need to add the directory containing mingwm10.dll to your PATH environment variable. I am surprised this was not configured correctly when you installed Qt/MinGW.
Control Panel -> System -> Advanced -> Environment Variables -> PATH
This isn't something that should be set in Qt. Your application is looking for a DLL it can't find, mingwm10.dll. You can either copy the DLL (and it's dependencies if there are any) near your .exe, or add the directory it's in to the environment variable PATH.
You can go to the location where your Qt application is installed and then navigate to "..\Qt\5.11.3\mingw53_32\bin" directory. The search for the missing .dll files, copy them to the location where your .exe file is situated and then re-run the application. If more than one files are missing try the same for them.

Resources