I am using Qt Creator to deploy my Qt application. On Mac, I'd like to include the required Qt libraries in the .app bundle. Is there any way to do it automatically using Qt Creator? Should I do it using the command-line? In that case, how should I do it?
The macdeployqt command line tool will add all the necessary Qt libraries that your Qt project references.
If you require any other, 3rd party libraries, you'll need to copy these manually and set the paths to them using the install_name_tool command.
You can check which libraries your application references using the otool command. For example: -
otool -L MyApplication.app/Contents/MacOS/MyApplication
For Qt Creator, I tend to write a script that adds the necessary libraries and calls macdeployqt and then under Projects, add a build step which calls the script.
An example script that would just add the Qt libraries would look something like this: -
#!/bin/bash
pwd
echo Copying QT libraries...
macdeployqt ./MyApplication.app
You can simply run macdeployqt foo.app. Qt Creator does not support this feature off-hand either. However, you can inject custom commands into your process in the QtCreator project settings.
It does not support QML just yet though. There are patches under codereview where it is coming. See the following link for details:
https://codereview.qt-project.org/#q,status:open+project:qt/qttools,n,z
Note: macdeployqt should not be used for usual development and debug! It should be only used when deploying. Otherwise, it is executed each time for building even if you just recompile the code due to a minor change for testing. This can slow down that process, but as for deploying, it should be alright.
On QT6 I was able to do it entirely within QT Creator:
In Projects/Build, add a custom build step after 'make' (probably only want to do this for your 'release' configuration):
Command: %{Qt:QT_HOST_PREFIX}/bin/macdeployqt
Arguments: %{ActiveProject:BuildConfig:Path}/%{ActiveProject:Name}.app - qmldir=%{ActiveProject:NativePath}
Working Directory: %{buildDir}
I was able to test it by airdropping the resulting .app onto my test machine.
reference: https://doc.qt.io/qt-6/macos-deployment.html#macdeploy
Related
I'm testing my OpenMP code in Qt creator using intel compiler icc. When I run it in Qt creator, there's always an error libiomp5.so: cannot open shared object file: No such file or directory.
Then I checked the LD_LIBRARY_PATH, everything was fine. I also used ldd command to see the linked libraries.
libiomp5.so => /opt/intel/compilers_and_libraries_2016.2.181/linux/compiler/lib/intel64/libiomp5.so (0x00007fadada3a000)
As shown, the program was actually linked to that library, and I could even run it well in terminal directly. It was so strange since I build the whole project using Qt creator.
Solved this problem by myself finally. Just add the path of the library into ld.so.conf. Then run ldconfig to update the cache.
I'm trying to make a bundle for a Qt based application using CMake.
Things seem to be working fine in terms of linkages, but trying to run the app gives me the error:
This application failed to start because it could not find or load the Qt platform plugin "cocoa".
Available platform plugins are: cocoa.
I'm not sure what this means as the two lines of output seem conflicting. The directory platforms/ (which contains libqcocoa.dylib) is in MyApp/Contents/Resources/bin/. Note that the MyApp executable is there as well.
While the platform library was in the correct position relative to the executable, the libqcocoa library was expecting other Qt libraries to which it was linked to be in specific directories. I used a script with install_name_tool -change commands to modify these paths.
I just installed QT 4.6 on snow leopard 10.6.3. I wrote a really simple program. I can generate a xcode project using qmake, but I can't step into QT function. How can I set it up?
By default, qt is built with a debug and a non-debug library. This is my understanding. For example,
% ls /Library/Frameworks/QtCore.framework/
Contents/ Headers# QtCore# QtCore.prl QtCore_debug# QtCore_debug.dSYM/ QtCore_debug.prl Versions/
Also, my default from source build of Qt 4.7 branch also has the *_debug libs.
Setting up for Xcode is cake, you just set up your project and
% qmake -spec macx-xcode
This -spec is the default for the official mac distribution, but if you build your own from source the default is macx-g++ which creates a Makefile project.
This generates a MyProject.xcodeproj that comes preconfigured to link all the necessary Qt frameworks, sets up paths, and has a Release and Debug build target set to the same options as the official SDK's.
This is all assuming you have your qt project file set up, if you need to generate that first from a raw source directory:
% qmake -project
Debugging works "out of the box" for these generated *.xcodeproj files. However, there's one little "hitch". Since Qt is full of custom data types, Xcode doesn't know how to display their "values" in the debugger's summary pane. So you can't see what value a QString has, for example.
There's a method of entering custom macros for display, but I've found these often (always?) don't work for QObjects.
To get that working, I've started a project that uses xcode's debugger c callbacks (also mentioned in the above linked article, though their example doesn't even work o.O). I call it Qt4DataFormatters.
I've just started it and have been adding types as the need arises. It's dirt simple to create one using the existing functions as a template though.
I haven't tried this on Mac, but on Linux you need to take the following process:
First, you need to setup Qt so that it has debugging symbols available to you:
./configure -debug-and-release separate-debug-info # other options
With the debugging symbols available, you should now be able to get valid stack traces.
When building your application with qmake, you need to have the debug (or debug_and_release) flag set in your project file:
CONFIG += debug
Once you've done that, you should only need to tell the debugger where the Qt source is located:
(gdb) dir /path/to/qt/src
After that, list should show you the actual Qt source code. You may need to add additional directories under the src directory for the debugger to pick it all up.
I am very new to Mac.
I downloaded QT SDK Mac Open source (http://get.qt.nokia.com/qtsdk/qt-sdk-mac-opensource-2010.02.dmg) and installed the Package.
I can run qmake, build samples and run demos,
but I cannot run configure (in order to build the Qt libraries statically).
It says: -bash: No such file or directory.
Documentation says I should run this in the "Qt root folder", but what is this folder in Mac?
I looked for it in /usr/bin, /usr/local/Qt4.6, /Developer/Tools/Qt.
Anyway, what is "configure" on Mac. is it an executable or a script?
Thanks a lot
The SDK download is a pre-built binary library. You need to download the source code version of Qt to be able to configure it to build as static libraries.
The configure script only comes with the source code download version.
I think the SDK only provides the headers and libraries hence the reason you can build applications using Qt. To build Qt itself you will need the source package which is a different download.
I'm trying to deploy my simple Qt project like a hello world.
I build it successfully and can also execute it on Qt-Creator. However, I can't execute the binary directly in the release folder due to some shared library errors.
So I just copy some essential librarys to the release folder such as qtcore.dll and qtgui.dll, but I can't still execute it.
How can I deploy my simple Qt project? Is there an another step to deploy it?
You also need to deploy the MINGW runtime dll (mingwm10.dll). This file is located in your Qt\2009.5\mingw\bin directory.
Also pay attention to whether your application is compiled in debug mode or release mode. I just made the test with an hello world type application and Qt Creator. In the debug folders, I copied libgcc_s_dw2-1.dll, mingwm10.dll, QtCored4.dll and QtGuid4.dll and it works.
Pay attention to the d in dll names, which stands for debug: QtCore d 4.dll.
See Qt 4.6: Deploying an Application in Windows.
For Qt 5, check this page.
If you don't want to have dependencies with qt/mingw dlls you should compile qt statically as explain here: http://qt.nokia.com/doc/4.6/deployment-windows.html#static-linking.
You may also use static linking, just add this line into the .pro file:
QMAKE_LFLAGS += -static-libgcc
I found the solution here and successfully tested on WinXP with QT creator 2.2.0
Try running dependency walker on it (http://dependencywalker.com/) to see which dlls are missing?
Generally, you won't need to move those Qt libraries into your local folder since the Qt installation should've added those libraries into your path.
One possibility is that you built debug, and the Qt debug dlls are named differently
copy all the qt dlls to your windows directory directly "C:\Windows\" and there will be no qt dll error
100% working and simple
nb: do not create a qt dll folder in your windows directory post them as they are