The packages I build following these instructions seem to crash at startup.
I'm building with:
cmake .. -DWITH_TESTS=OFF -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.7.0/lib/cmake -DCMAKE_BUILD_TYPE=Release
make -j8
make package
Dependencies:
cmake-3.6.2
qt5-5.7.0
libgcrypt-1.7.3
libmicrohttpd-0.9.51
Crash log: https://gist.github.com/agunnerson-ibm/a5e22bbe773b1cc15431cf3850585ee9
Files included in KeePassX.app: https://gist.github.com/agunnerson-ibm/cff7af5c0a0cf7c11927b7e1b600668a
If I try to run /Applications/KeePassX.app/Contents/MacOS/KeePassX manually, I get the following:
This application failed to start because it could not find or load the Qt platform plugin "cocoa"
in "".
Reinstalling the application may fix this problem.
[1] 53014 abort /Applications/KeePassX.app/Contents/MacOS/KeePassX
Can you show me the output of these command:
which macdeployqt -> will show which version of macdeployqt are installed and whereotool -L libqcocoa.dylib -> from the .app folderThanks
Sure. I do not have macdeployqt in my $PATH. I assume that CMake will find it based on CMAKE_PREFIX_PATH. libqcocoa.dylib does not exist in the .app folder.
EDIT: This is what CMake finds (taken from CMakeCache.txt):
//The directory containing a CMake configuration file for Qt5Concurrent.
Qt5Concurrent_DIR:PATH=/usr/local/Cellar/qt5/5.7.0/lib/cmake/Qt5Concurrent
//The directory containing a CMake configuration file for Qt5Core.
Qt5Core_DIR:PATH=/usr/local/Cellar/qt5/5.7.0/lib/cmake/Qt5Core
//The directory containing a CMake configuration file for Qt5Gui.
Qt5Gui_DIR:PATH=/usr/local/Cellar/qt5/5.7.0/lib/cmake/Qt5Gui
//The directory containing a CMake configuration file for Qt5LinguistTools.
Qt5LinguistTools_DIR:PATH=/usr/local/Cellar/qt5/5.7.0/lib/cmake/Qt5LinguistTools
//The directory containing a CMake configuration file for Qt5Network.
Qt5Network_DIR:PATH=/usr/local/Cellar/qt5/5.7.0/lib/cmake/Qt5Network
//The directory containing a CMake configuration file for Qt5Test.
Qt5Test_DIR:PATH=/usr/local/Cellar/qt5/5.7.0/lib/cmake/Qt5Test
//The directory containing a CMake configuration file for Qt5Widgets.
Qt5Widgets_DIR:PATH=/usr/local/Cellar/qt5/5.7.0/lib/cmake/Qt5Widgets
"make package" actually uses DeployQt4 from cmake and not macdeployqt.
@rockihack This explain everything.
@agunnerson-ibm can you try this patch
Paste the patch below in a file called appleQt5.patch in the main KeePassXR folder,
then in a terminal type git apply --check appleQt5.patch and if there aren't error git apply appleQt5.patch.
After that you can do make clean, and recompile the source code
appleQt5.patch
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c7d8cbf..a2401a9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -215,8 +215,8 @@ if(APPLE)
set(CPACK_PACKAGE_FILE_NAME "${PROGNAME}-${KEEPASSX_VERSION_NUM}")
include(CPack)
- include(DeployQt4)
- install_qt4_executable(${PROGNAME}.app "qjpeg;qgif;qico;qtaccessiblewidgets")
+ include(DeployQt5)
+ install_qt5_executable(${PROGNAME}.app "qjpeg;qgif;qico;qtaccessiblewidgets")
endif()
if(MINGW )
There is no official DeployQt5, thats why I use macdeployqt for my builds.
(https://github.com/rockihack/keepassx/blob/mac-autotype/build_mac.sh)
However there is a macdeployqt/homebrew issue (since qt 5.6.1) with fixing up the app bundle.
(https://github.com/Homebrew/homebrew-core/issues/3219)
You can use my shell script as a workaround.
#!/bin/bash
# Canonical path to qt5 directory
QT5_DIR="/usr/local/Cellar/qt5/5.7.0"
# Change qt5 framework ids
for framework in $(find "$QT5_DIR/lib" -regex ".*/\(Qt[a-zA-Z]*\)\.framework/Versions/5/\1"); do
echo "$framework"
install_name_tool -id "$framework" "$framework"
done
@TheZ3ro Well, that explains a lot. However, while it no longer crashes, it still does not open.
Running the binary from the command line still results in:
This application failed to start because it could not find or load the Qt platform plugin "cocoa"
in "".
Reinstalling the application may fix this problem.
[1] 40509 abort /Applications/KeePassX.app/Contents/MacOS/KeePassX
and the libqcocoa.dylib library still does not exist. I wiped out the build directory before building and the following is what's changed in my local repo:
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c7d8cbf..3bff984 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -225,6 +225,6 @@ if(MINGW )
set(CPACK_PACKAGE_FILE_NAME "${PROGNAME}-${KEEPASSX_VERSION_NUM}")
include(CPack)
- include(DeployQt4)
- install_qt4_executable(${PROGNAME}.exe "qjpeg;qgif;qico;qtaccessiblewidgets")
+ include(DeployQt5)
+ install_qt5_executable(${PROGNAME}.app "qjpeg;qgif;qico;qtaccessiblewidgets")
endif()
@rockihack I was thinking that there was a DeployQt5.cmake lib.
I've found this but IDK if it's good https://github.com/Answeror/ACMake/blob/master/DeployQt5.cmake
Anyway I don't like using an external script to compile the macOS verison when we have CMake/CPack
I will develop a patch based on Cmake ASAP.
@TheZ3ro You can also run macdeployqt from cmake. There is no need for an extern shell script.
It's also possible to create a package with macdeployqt and completely remove DeployQt4
(there is also windeployqt and linuxdeployqt).
I was testing a solution with
find_program(MACDEPLOYQT_APP macdeployqt)
execute_process(COMMAND ${MACDEPLOYQT_APP} src/KeePassX.app)
Instead of deployQt4.
Does macdeployqt also replace install_qt4_executable(${PROGNAME}.app "qjpeg;qgif;qico;qtaccessiblewidgets") ?
@TheZ3ro Yes, you can remove it.
include(DeployQt4)
install_qt4_executable(${PROGNAME}.exe "qjpeg;qgif;qico;qtaccessiblewidgets")
@rockihack and after the macdeployqt we need to add the install_name_tool. Ok I will work on this
@TheZ3ro No, you don't need to run install_name_tool manually.
Normally macdeployqt handles it, but there is an open issue with macdeployqt and the qt frameworks shipped with homebrew (link above).
As a workaround run my shell script once after installing qt5 with homebrew,
it will fix the framework ids and make macdeployqt work as expected.
@rockihack oh nice so you have to do this only 1 time and not every time you deploy
I'm closing this as I'm able to make a fully functioning build with #63.
EDIT: I did use @rockihack's script to patch the Qt5 frameworks.
Great to hear!
Yes, @rockihack's script is also in the wiki page about building the MacOS environment
Most helpful comment
I'm closing this as I'm able to make a fully functioning build with #63.
EDIT: I did use @rockihack's script to patch the Qt5 frameworks.