Qt5 cannot find platform plugins Mac OS X - c++

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.

Related

QtCreator issues ld: warning: directory not found for vcpkg Qt

I installed Qt5 with vcpkg on macOS Catalina. And installed QtCreator using the online installer.
Then on QtCreatpr, Preferences, Kits, Qt Versions I added qmake from both
/Users/user/vcpkg/installed/x64-osx/tools/qt5/bin
/Users/user/vcpkg/installed/x64-osx/tools/qt5/debug/bin
It seems to be working fine but there is one thing, when building a project it returns
ld: warning: directory not found for option '-L/Users/user/vcpkg/installed/x64-osx/debug/lib/manual-link'
What is that warning telling me?
What is that warning telling me?
Just that the directory /Users/user/vcpkg/installed/x64-osx/debug/lib/manual-link does not exist. If you want to get rid of the error just create the folder itself. vcpkg is probably manually adding it somewhere without checking if it actually exists.

Why my QtRPT project file is not running in QtCreator?

I have QtRPTProject to run in the QtCreator but It is showing errors like " Cannot run compiler 'g++'. Maybe you forgot to setup the environment?" and "Project ERROR: Unknown module(s) in QT: script" while building.Any help ??
Project ERROR: Unknown module(s) in QT: script
This means that the module Qt Script is not installed.
This module has been deprecated and is not installed by default, you have to opt-in.
The exact procedure on how to install it depends on how you installed Qt in the first place. If you used the online installer, it is just a matter of running the "Maintenance Tool" and checking the Qt Script checkbox.
Cannot run compiler 'g++'. Maybe you forgot to setup the environment?
This means that Qt Creator cannot find the c++ compiler.
That means that you have not installed a compiler, or not configured Qt Creator correctly.
Again the exact procedure depends on your system and which compiler you want to use. If you are on Windows, the Qt Maintenance Tool offers to install MinGW for your. Like for Qt Script it is just a matter of checking the right checkbox. Be sure to select the MinGW version that matches the version of Qt you selected.
If you need more help, please edit your question and add details about your system and your current installation.

Error deploying Qt application on OS X

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.

Unable to build for Windows on Linux, with MinGW

Because I am not a Java enthusiast, I decided to use C++ and Qt for one of my projects. However, I came across the big cross-compiling Qt problem, and I am unable to produce an .exe file for Windows users.
My setup
Linux Ubuntu 12.04, with Wine and Qt. qmake -v gives the following output :
QMake version 2.01a
Using Qt version 4.8.1 in /usr/lib/x86_64-linux-gnu
I also have a MinGW32 compiler, which can be found at /usr/bin/i586-mingw32msvc-g++. My Wine drive_c folder contains the following Qt directories :
$HOME/.wine/drive_c/Qt/Qt5.2.0/5.2.0/Src
$HOME/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32
The mingw48_32 directory contains the necessary include/ and lib/ directories, which are used in my mkspec file, /usr/share/qt4/mkspecs/win32-x-g++/qmake.conf :
QMAKE_INCDIR_QT = /home/me/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32/include
QMAKE_LIBDIR_QT = /home/me/.wine/drive_c/Qt/Qt5.2.0/5.2.0/mingw48_32/lib
The problem
According to most guides I've found about Qt cross-compiling, my setup should be enough to run a simple :
qmake -spec win32-x-g++
make
wine /path/to/my/application.exe
But... nothing's linked. QApplication and every other symbol I use in my program are "not found". No QApplication, no QPushButton, no connect(), no SIGNAL(), no SLOT()...
My objective here is to successfully configure QtCreator to use this setup (in an independent build configuration), so that it can build a Linux executable (through the first and working configuration), and a Win32 .exe (through the MinGW setup above). However, I cannot modify a single build step in QtCreator :
Cannot add a "MinGW" toolchain : it is not available in the "Add" dropdown list.
Cannot change the -spec parameter value in the project build configurations panel. The field is non-editable.
Despite guides and solutions I found all over the Internet, my only solution so far is to send my source code to a virtual Windows machine, and have it create a new project with it. On this VM, I could probably compile for Windows... But of course, this doesn't actually sound like a real "solution" to me...
Is there any way Qt(Creator) has finally made cross-compiling easier now ? I'm getting a bit tired of "symbol not found" errors...
First,
sudo apt-get install mingw-w64
Then, check if Qt Creator finds the toolchain.
Next, until Ubuntu starts providing a mingw-w64-qt package, download the Qt source and build it. This is bound to get messy, and maybe even the simplest thing to do is to install WINE and use a Windows Qt version.

Error: Program "make" not found in PATH

I have the following error in Eclipse CDT (using Windows 7). How to correct it?
Error: Program "make" not found in PATH
PATH=[C:\cygwin\bin;C:/Program Files/Java/jre1.6.0/bin/client;C:/Program Files/Java/jre1.6.0/bin;C:/Program Files/Java/jre1.6.0/lib/i386;C:\Program Files\WinRAR;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\cygwin\bin\;C:\Users\user\AppData\Local\Temp\Rar$EX00.502\eclipse]
Path Environment variable has the following
C:\cygwin\bin\
BASH
You should install make package in cygwin. To do this execute cygwin setup.exe and when the window of packages opened, search make and install it. This is gonna solve your problem i think
You're missing make which is used for processing Makefiles to build programs.
Also to me it seems that this is more related to superuser.com, here is a similar question.