moving Qt directory - qt

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/

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 Release qt.conf

When I release my Qt project, I want to redistribute the QtCore5.dll and Qtxxx.dll files.
How can I make myapp.exe to find them automatically?
The best way of doing this seems to be by editing a qt.conf file placed in the same folder as my executable.
myapp.exe is in c:\myapp\bin folder
The dlls are in c:myapp\common folder
"Better" way is to put your qt.conf into your resources :/qt/etc/qt.conf. This way has highest priority for resolving platform dependencies.
In our project we use cmake to generate necessary qt.conf file: in debug mode we put path to installed Qt binaries and in release - to local (deploy) folder.
Qt5xxx.dll files are linked, so you should place it in same folder, or make them available throught PATH environment variable. If you really want such exotic redistribution system (please, say real reason) - you may create your own platform-specific launcher, that will load necessary .dll's from any path.
Just put all required dll files into the same directory as your executable.
Note, that there are more files to distribute than just Qt*.dll - you will need proper plugin from platforms subdirectory and many more. Read Qt documentation on deploying application under Windows - it will teach you all required files.

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.

Qt How to make and install plugins?

I would like to use the Qt Quick Components for Desktop mentioned here: http://labs.qt.nokia.com/2011/03/10/qml-components-for-desktop/
The author gives the following installation-instructions:
Since all of this is developed as a plugin to Qt itself, all you need to get started is the Qt 4.7.2 SDK. Just check out the http://qt.gitorious.org/qt-components/desktop and do the equivalent of a qmake && make install on your system.
I cloned the repository, executed qmake, mingw32-make and mingw32-make install on it in the command-line.
A new folder was created which includes the files libstyleplugin.a and styleplugin.dll.
I just don't know what to do with them. The sample-qml-files (using the components I try to install here) show nothing in the QML-Viewer, which means they aren't isntalled correctly.
So what am I supposed to do? (btw. I'm on Windows).
Hedge, I've done that on Linux but I believe you will be able to do the same on Windows. You already built the plugin which is good. Cause it seems "make install" doesn't really work (lets not blame the trolls - its just an experimental project), you need to do that manually. Now you need to do the following:
Create "imports" directory inside the directory whether you installed Qt.
Create "Qt/labs" directory inside that "imports" directory so overall it looks like this: YOUR_QT_DIR/imports/Qt/labs.
Copy "components" directory from the director where you built the components to "YOUR_QT_DIR/imports/Qt/labs" so it looks like this: YOUR_QT_DIR/imports/Qt/labs/components.
Go to "examples" directory in the directory where you built the components. You will find Browser.qml, Gallery.qml and Panel.qml files there. Open say Gallery.qml in a text editor and replace the following two lines on the top:
import "../components"
import "../components/plugin"
with
import Qt.labs.components 1.0
save changes and run Gallery.qml in qmlviewer. You should be able to run it.
Also you could leave the import statements from Gallery.qml as they were but that would rely on the relative directory where you built the components and won't work anywhere else.
Hope that helps
On Windows my directory ended up being C:\QtSDK\Desktop\Qt\4.7.3\mingw.
Hope this helps!

Qmake does not support build directories below the source directory

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

Resources