Qt for mac os - deploy project to app file - macos

I have read different posts and the Qt documentation explaining command lines in shell but I cannot get through the installation of static library (and I suppose shared frameworks would be even harder) in order to produce an "app" file from my project. But I don't know why...
Would anyone be able to explain me how to get through this? Is there no "easy" way to produce a .app from Qt directly?

Assuming you are using the qmake to build your project, you should have in your *.pro file:
QT += gui
TEMPLATE = app
The QT variable will probably have more than just gui, but the gui is necessary for you to create an app bundle directory structure, so make sure to have it in place. The TEMPLATE = app is also mandatory.
After compiling with qmake, you should have working app bundle, which depends on your Qt installation. To make the bundle independent from your Qt installation (in other words, to make the bundle contain the Qt for its own use), use the macdeployqt tool from your Qt, like this:
macdeployqt your_app_name.app

Related

Can #rpath be modified in a makefile with g++ on OSX?

I am trying to dynamically link to a custom dynamic library in an OSX application. For various reasons, I don't want to have specify environment variables after the build. I want my build environment to provide everything needed to run the application.
I am compiling the application with gcc using a makefile (actually, I a script that makes calls to qmake and does some automated editing.). On linux I would just do:
-Wl,-rpath,<path/to/dynamic/library>
but for whatever reason OSX doesn't abide by these rules. I keep getting
#rpath/mylib.dylib Library not loaded
when I try to run the app.
I hope this is clear. I want the app itself to know where to look for mylib.dylib. I know how to do this in Xcode with LLVM, but it would be nice if I could do it with a makefile and gcc as well. I don't want to have to setup a whole Xcode project for simple little apps like this (of which I need to make many that link to my library). Qmake etc. is far more convenient.

Import Qt Creator project from mac into windows - How to get UI informations?

i developed a qt-project on Qt Creator for Mac OS. Now i want to import this projekt on Windows (Qt Creator, Compiler, libs are already installed).
Compiling the project already works. But when running, it crashes. On Mac I changed some classes in the UI (Qt Creator). So I did the same on Windows. But it still crashes. I also tried to copy the ui_mainwindow.h from Mac to Windows. Doesn't work.
I remembered, that I added some slots in the UI (Qt Creator) to make buttons functional. And only the mainwindow.h and mainwindow.cpp changed (in my gitHub version). But usually you have to add connect(SIGNAL ... SLOT ...) to add functionality to Buttons. So I searched for this functions, and found their names in moc_mainwindow.cpp
And this moc_mainwindow.cpp file is also on windows, but contains different stuff (not my in Mac UI added slots). And when copying my project from Mac to Window the folder doesn't contain moc_mainwindow.cpp. So it has to be build by the system.
Does anybody know how to get the SLOT information from my Mac project to the moc_mainwindow.cpp on Windows. And is the changing of this file enough or do I have to change also other files to get my project work on Windows?
Thanks
you need to run qmake on the .pro file and run make on the generated files
in qCreator you can do this in the build menu

Qt Creator: Projects that use other projects as libraries

I've written a small library as a Qt project using Qt Creator, now I want to create a small GUI application that can be used to test it as part of the development process, so it could be like this:
Project root at:
~/code/mylib
Library project and associated code:
~/code/mylib/corelib/corelib.pro
GUI test tool and associated code:
~/code/mylib/libgui/guitool.pro
So far I've only been able to make things work by setting up LIBS+= in the GUI project's .pro file, manually building the library, copying the library's .a file to the GUI directory, and rebuilding the GUI project. A tedious process. Worse: I'm developing the project now on Linux but need to make it build on Linux and Windows, and this manual build style will probably make that harder.
I suppose there's a way to do make Qt Creator aware of the relationships between the projects, so for example building the GUI tool in debug mode use the debug version of the library, or making changes to the corelib would necessitate a build in the GUI, building on some OS would use the libraries OS-configuration...etc
This kind of thing is a couple of clicks away in Eclipse and Visual Studio, but I can't seem to get it working in QtCreator. I've tried "Add library->Internal library" and creating a 'subdirs' project but neither seems to work. I feel it's probably a simple step that I'm missing somewhere, any help?
Try again to use subdirs feature. It have own wizard "Project with subdirectories", but in your case it's easier to write it manually (in example I've added "ordered" to ensure that order of compilation is always correct).
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = corelib guitool
Than you can add libary to your GUI application with wizard (accessible from context menu inside .pro).

How to include Qt libraries with CMake inside a .app project on OSX?

I've created a Qt project using CMake as build system. I would like to include in the deployment phase, the necessary Qt frameworks
Qt3Support.framework/ QtNetwork.framework/ QtXml.framework/
QtCore.framework/ QtOpenGL.framework/
QtGui.framework/ QtSql.framework/
in order to be ready to distribute my program as standalone dmg.
This is usually done with macdeployqt command but it gives me a lot of errors like this:
ERROR: "strip: for architecture x86_64 object:
/Users/rs/build/myapp.app/Contents/Frameworks/QtXmlPatterns.framework/Versions/4/QtXmlPatterns
malformed object (unknown load command 5)
so I want to be able to do it directly in the deployment phase, is it possible?
I was using DeployQt4 and BundleUtilities for some time until I ran into a problem with it which wasn't easy to fix according to one of the authors.
I ended up writing a ruby script that does what BundleUtilities does barring that problem. My script has a limitation currently comparing to the BundleUtilities - it doesn't handle bundles with multiple executables. Writing the same functionality in cmake is beyond my degree of masochism (I managed to understand what BundleUtilities does and how but was appalled by the contraptions they had to use to organize data in memory).
The script itself is available here: https://github.com/artm/vision-ui-skeleton/blob/master/ruby/fixup/fixup.rb
It is used from cmake at the bottom of: https://github.com/artm/vision-ui-skeleton/blob/master/cmake/QArtmRelease.cmake
It works with ruby that comes with OSX 10.6.x and probably higher.

Application won't launch from Creator

my Qt application won't launch from Qt Creator, however I can run the .exe directly from the release folder. Why is that ? I am totally lost here. In Qt Creator, I just get a message telling me that my application just crashed, with the code -1073741515.
Qt Creator must be pointing to the wrong dlls. You could reinstall the QtSDK and it should fix finding the runtime dlls in the IDE (Qt Creator).
http://www.daniweb.com/.../ok-so-whats-error-1073741515-again
On this post here they said they fixed it by updating the PATH in Qt. Here is the portion that gets prepended to my PATH variable as seen in the picture below:
C:\QtSDK\mingw\bin;C:\QtSDK\Desktop\Qt\4.7.3\mingw\lib;C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin;
Here is a screenshot showing how to access that:
Another option is you could go into the QtSDK folder, find the bin folder for compiler and platform you are using and put it in the path for your system. Then Qt should be able to run the program just by finding the dlls in the system path.
Possibly the shortest option, but the trickiest would be to go into Qt Creator > Tools > Options > Qt4 and make sure you have something that looks similar to this:
.
Going by this answer it looks as if it's failing to find a shared library.
Check the appropriate path environment variable in the project's run settings and make sure it's got everything it needs.

Resources