This guide walks through the steps I followed to build
KeePassX on my Mac. I found I needed
to install many prerequisites in order for it to build.
Install GnuPG libraries
First download and install libgpg-error.
http://www.gnupg.org/download/#libgpg-error
Build and install. (Should go to /usr/local/*
.)
./configure
make
sudo make install
Then, download and install libgcrypt.
http://www.gnupg.org/download/#libgcrypt
Build and install.
./configure
make
sudo make install
Install Qt4
Download and install Qt4 from http://qt.nokia.com/downloads.
Note that in order for me to get the installer to work, I had to install
to a subdirectory of my home directory, not in a global location. I think
this is because the post-install scripts don’t ask for the proper
permissions. They’ll fail if you don’t have write permissions to
a directory.
After it was installed, I had to add the Qt utilities to my
~/.bash_profile
. For me, these were located in
~/QtSDK/Desktop/Qt/474/gcc/bin
.
Build KeePassX
In order to build KeePassX, I had to add a “bundle
destination” to src/CMakeLists.txt
.
$ diff src/CMakeLists.txt.old src/CMakeLists.txt
add_executable( ${PROGNAME} WIN32 MACOSX_BUNDLE main.cpp )
target_link_libraries( ${PROGNAME} keepassx_core \
${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} \
${GCRYPT_LIBRARIES} ${ZLIB_LIBRARIES} )
- install(TARGETS ${PROGNAME} DESTINATION ${BIN_INSTALL_DIR})
+ install(TARGETS ${PROGNAME}
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
Then, as the INSTALL file says, run
mkdir build
cd build
cmake ..
make
Notes
For this project, I thought I had to tell configure to use the 32-bit
architecture, since it couldn’t find symbols when I tried the default
64-bit. (It turns out that I just hadn’t installed the libraries in the
correct order.)
For future reference, if you need to force a 32-bit architecture, do
this.
./configure CC="gcc -arch i386" CXX="g++ -arch i386"
make
sudo make install