Error deploying Qt application on OS X - c++

I'm trying to deploy a Qt application on OS X using macdeployqt:
macdeployqt MyApplication.app -dmg
The application uses the Qwt library, which is being included in the PRO file as follows:
macx: QWT_ROOT = /usr/local/qwt-6.1.0
include ( $${QWT_ROOT}/features/qwt.prf )
When I run the macdeployqt command I get the following error message:
ERROR: no file at "/Library/Frameworks/qwt.framework/Versions/6/qwt.framework/Versions/6/qwt"
I'm not sure but it seems the deployment step is looking for the Qwt library on the wrong path, for example:
"/Library/Frameworks/qwt.framework/Versions/6/qwt.framework/Versions/6/qwt"
When it should be:
"/Library/Frameworks/qwt.framework/Versions/6/qwt"
How can I solve it?

I have uninstalled other qt versions using brew list, brew remove qt and brew remove qt5. I also noted that I had pyqt installed (and I was not using it), so I also remove it using brew remove pyqt.
Then, I have reinstalled Qt 5.3.2 and had other issues:
Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
Which was solved changing the isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null"))) command from the Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf file to isEmpty($$list($$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null"))), as explained here: Qt Creator - Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild
and
Could not resolve SDK path for 'macosx10.8'
That was solved by changing the QtPath/5.3/clang_64/mkspecs/qdevice.pri from !host_build:QMAKE_MAC_SDK = macosx10.8 to !host_build:QMAKE_MAC_SDK = macosx10.12, as explained here: Error: Could not resolve SDK path for 'macosx10.8'
So, I run the command from my Qt directory:
/Users/kuser/Qt5.3.2/5.3/clang_64/bin/macdeployqt MyApplication.app -dmg
and it worked.
I found these solutions in comments from the following question:
Qt5 cannot find platform plugins Mac OS X
Note: this does not solve the macdeployqt error directly, but as it is part of the Qt installation, reinstalling it solved my problem.

Related

How to install Qt Serialport on macOS?

I'm trying to compile this code where the .pro file includes a
QT += serialport
gives me a
Project MESSAGE: Warning: unknown QT: serialport
error. Without Qt, I would use CMake and install the package via vcpkg, Conan, HomeBrew, or something like that. But not sure if Qt has its own package manager. I would appreciate it if you could help me know what is the most canonical way to install and include this library.
P.S.1. In the comments, I'm being told that I need to use Qt's Maintenance Tool, which is sorta the internal package manager for Qt, to install QtSerialPort module. Given that I don't know how to install that via HomeBrew, I installed Qt Creator from the Qt website. I found the Maintenance Tool in <install_dir> the installation folder /Users/<user>/Qt/MaintenanceTool.app which I could open from the terminal by open MaintenanceTool.app while being in that folder. However, I can not see any QtSerialPort module in the options, nor a way to search.
P.S.2. Posted a new question here.
P.S.3. I think this issue arises because I had multiple versions of Qt installed. once I searched for locate qmake and found out the other versions I have installed (e.g., /System/Volumes/Data/usr/local/Cellar/qt/5.14.1/bin/qmake) I could just run that and the MakeFile was generated.

No configure file to make static version of qt

I want to deploy my qt program using static linking following this documentation:
http://doc.qt.io/qt-5/linux-deployment.html
When I try the command "./configure -static -prefix /usr/bin", I get an error:
"bash: ./configure: No such file or directory"
I understand that happens because there is no configure file. In the documentation it says "/path/to/Qt". /usr/bin seems to be the path where qt is installed.
Why is it not working? Am I in the wrong directory?
I wrote the application in C++ using the Qt Creator on a Raspberry Pi 2 with Raspbian Jessie. I want to deploy it so I can use it on another Raspberry that has minimal functionality without desktop-gui or qtcreator installed. I am using Raspbian Jessie Lite on that one.
I had this same problem after installing qt creator 5.10.
The qt directory does not have a configure file. However, the source directory for qt does.
In my installation, that is:
~/qt/5.10.1/Src
If you cd into that directory, you can run the ./configure command. At least i am able to.

Error: Could not resolve SDK path for 'macosx10.8'

So I just installed qt around 5 minutes ago, and when I wanted to code a simple line of text in the Push Button and try to run it, I got this error:
:-1: error: Could not resolve SDK path for 'macosx10.8'
Could anyone help? Also, if you need me to do something, could you explain like I'm five please. (Not actually like I"m five but I hope you know what i mean)
The problem is that the online installer for Qt currently supports OSX 10.8 (Mountain Lion) by default, and I'm guessing you are on 10.9 (Mavericks) or greater.
There is a workaround:
Navigate to where you installed Qt (default /Users/your username/Qt) using finder
Go to the subdirectory 5.3/clang_64/mkspecs directory
Open the file called qdevice.pri with a text editor
Change the line
!host_build:QMAKE_MAC_SDK = macosx10.8
to:
!host_build:QMAKE_MAC_SDK = macosx10.9 if you are on OS X 10.9 (Mavericks), or
!host_build:QMAKE_MAC_SDK = macosx if you are on OS X 10.10 (Yosemite)
Save the file and restart Qt Creator
I'm running Qt 5.7.1 on Mac OS 10.12.2.
None of the above answers involving adding !host_build:QMAKE_MAC_SDK = macosx10.12 to a file worked for me.
What did work was a small reconfigure on the XCode side of things as described here, the key step being entering
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
in the command line.
What caused the problem for me was that I installed the XCode command line tools before installing XCode itself which apparently makes it hard for Qt to find the Mac OS SDK.
For Qt 5.7 and macOS Sierra
Navigate to where you installed Qt (default /Users/your username/Qt) using finder
Go to the subdirectory 5.7/clang_64/mkspecs directory
Open the file called qdevice.pri with a text editor
Add line on end file
!host_build:QMAKE_MAC_SDK = macosx10.12
add
QMAKE_MAC_SDK = macosx10.12
to your .pro file. Done and Done. (for some, qdevice.pri does not contain the !host_build line, and adding it does nothing, so just set the variable directly in the .pro file).
I have confirmed that you will eventually also have to implement this https://github.com/Homebrew/formula-patches/blob/master/qt5/xcrun-xcode-8.patch: which is just a matter of changing one line in your default_pre.prf file (for your appropriate machine aka Mac/PC, etc...)
I recently upgraded from OSX 10.8 to 10.12 and ran into this using Qt 5.7
The issue was resolved by a combination of:
1) FranklinA's suggestion:
Open Xcode->Preferences->Locations->command line tools..select the CLT
xcode-select active developer directory error
..and..
2) adding to the .pro file the following line:
QMAKE_MAC_SDK = macosx10.12
Coming to this late.
I had this error an all I needed to do was open up the actual Xcode app (which for some reason was not findable by spotlight but was in the applications folder), accept some terms, and let it do some config.
In QT 5.7.0, Xcode 8.0 (8A218a), Mac OSX El Capitan (10.11.6), this issue happened from sudden in already configured environment. 5.7/clang_64/mkspecs/qdevice.pri no longer contains QMAKE_MAC_SDK line to modify.
I suspect some XCode part got silent update and I issue appeared again. This worked:
open XCode and let it reconfigure again (automatic action upon start)
delete .pro.user file from the project
reopen project in QT
Using QT 5.7.0, Mac OSX Sierra (10.12), XCode 8.0, I got the typical error coming from searching in:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
instead of:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
Adding the line
!host_build:QMAKE_MAC_SDK = macosx10.12
to the Qt/5.7/clang_64/mkspecs/qdevice.pri file, worked for me.
In my case , I have just opened xcode again. It start installing some components. Once it finished , I open Qt again and everything start working fine.
All I had to do was accept the Xcode licence by running: sudo xcodebuild -license accept

Qt5 cannot find platform plugins Mac OS X

I am trying to deploy a Qt program on Mac according to this link. After going through with otool -L on my executable and all of the libraries that it depends on, which I copied into the application bundle, I get this error in QtCreator's application output when I try to run it.
This application failed to start because it could not find or load the Qt platform plugin "cocoa".
Reinstalling the application may fix this problem.
The program has unexpectedly finished.
I've tried copying the qt platform plugins libqcocoa.dylib and changing the plugins directory in qt.conf, according to this, but it still fails.
Also worth pointing out, I first tried to use qt's macdeployqt tool, but it fails with this message, despite being the first time I run it on the executable:
ERROR: Could not find bundle binary for "MyProgram.app/Contents/MacOS/MyProgram"
ERROR: "otool: can't open file: (No such file or directory)"
WARNING:
WARNING: Could not find any external Qt frameworks to deploy in "MyProgram.app/Contents/MacOS/MyProgram"
WARNING: Perhaps macdeployqt was already used on "MyProgram.app/Contents/MacOS/MyProgram" ?
WARNING: If so, you will need to rebuild "MyProgram.app/Contents/MacOS/MyProgram" before trying again.
ERROR: Could not find bundle binary for "MyProgram.app/Contents/MacOS/MyProgram"
ERROR: file copy failed from "/Developer/Applications/Qt/plugins/platforms/libqcocoa.dylib"
ERROR: to "MyProgram.app/Contents/MacOS/MyProgram/Contents/PlugIns/platforms/libqcocoa.dylib"
ERROR: file copy failed from "/Developer/Applications/Qt/plugins/printsupport/libcocoaprintersupport.dylib"
ERROR: to "MyProgram.app/Contents/MacOS/GraphiteMiniEditor/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib"
Re macdeployqt fails: it seems like, for the argument to macdeployqt you are passing the path to the executable instead of the path to the bundle. I.e. just pass .../MyProgram.app instead of .../MyProgram.app/Contents/MacOS/MyProgram.
(But I am also unable to get it find libqcocoa, in a sandboxed app. I may resort to linking that statically into my app.)
To give Kamil Klimek's solution some more attention (It solved the problem for me):
I had the same problem when I installed QtCreator (Qt 5.x) with the offline installer, but apparently also had Qt (4.x) installed through Homebrew (probably pulled in as a dependency). Compiling the code with 5.x, and deploying it with the 4.x macdeployqt script doesn't work.
So, make sure that e.g.:
which macdeployqt
calls macdeployqt from the same Qt version / path used to compile the code.
I had this error with OS X Lion, using Qt 5.4.2. When I installed the Xcode command line utilities, then the error went away and macdeployqt worked.

How to install gtk on OSX for use with g++/gcc compiler

I already asked this question at apple.stackexchange.com, but I was told it was the wrong place for this question - so I will ask it here, as I was suggested to do.
At my university we got the task to implement a c-program which has a GTK-GUI. The GTK-GUI is already implemented, we just have to implement a algorithm which hands it some data.
I already got gcc/g++ working. But when i try to compile the project the compiler returns the error, that it does not find the gtk:
fatal error: 'gtk/gtk.h' file not found
#include <gtk/gtk.h>
^
So my question is:
How do I install gtk on OSX Mavericks for using it with gcc/g++ compiler?
My setup: MacBook Pro Retina Mid 2012 with OSX Mavericks. Homebrew is installed and working if it could be useful for the installation.
(Of course the Apple Command Line Developer Tools are installed)
I finally solved the Problem. tojanfoe suggested in a comment the link http://www.hardcoded.net/devlogs/20120426 which turned out to not be helpful.
This is how i solved it:
1.a) Installation of GTK+ 2.x:
brew install gtk+
1.b) Installation of GTK+ 3.x:
You can install gtk+ 3.x via home brew too if you need that, but the 2.x version is enough for my purposes. The command would be:
brew install gtk+3
2.)
But after the installation I had the problem, that cairo could not be found. So i solved it this way:
export PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.12.16/lib/pkgconfig/
3.)
Then the compiler said it could not find the package 'xcb-shm', required by 'cairo'. This can be solved this way:
export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig
After this command the compiler worked as expected.
You can download precompiled Gtk2 Framework from: http://r.research.att.com
http://r.research.att.com/libs/GTK_2.24.17-X11.pkg,
or
http://r.research.att.com/libs/GTK_2.18.5-X11.pkg
And Gtk3 Framework from: http://www.tarnyko.net/dl/gtk.htm