2024-06-24 07:43:59 -04:00
# Build and Install KeePassXC
2016-10-26 14:19:28 +02:00
2017-11-26 16:36:46 -05:00
This document will guide you through the steps to build and install KeePassXC from source.
2019-11-23 15:39:03 +00:00
For more information, see also the [_Building KeePassXC_ ](https://github.com/keepassxreboot/keepassxc/wiki/Building-KeePassXC ) page on the wiki.
2016-10-26 14:19:28 +02:00
2020-07-06 18:26:54 -04:00
The [QuickStart Guide ](https://keepassxc.org/docs/KeePassXC_GettingStarted.html ) gets you started using KeePassXC on your Windows, macOS, or Linux computer using pre-compiled binaries from the [downloads page ](https://keepassxc.org/download ).
2016-10-26 14:19:28 +02:00
2024-06-24 07:43:59 -04:00
## Toolchain and Build Dependencies
2016-10-26 14:19:28 +02:00
2023-12-09 14:43:29 +01:00
The following build tools must exist within your PATH:
2016-10-26 14:19:28 +02:00
2024-06-24 07:43:59 -04:00
* cmake (>= 3.16.0)
2023-12-09 14:43:29 +01:00
* make (>= 4.2) or ninja (>= 1.10)
2024-06-24 07:43:59 -04:00
* g++ (>= 9.3.0) or clang++ (>= 10.0)
2022-03-20 09:01:18 -04:00
* asciidoctor (>= 2.0)
2016-10-26 14:19:28 +02:00
2023-12-09 14:43:29 +01:00
* Besides a working C++ toolchain, KeePassXC also has a number of direct build and runtime dependencies. For detailed information about how to install them, please refer to the GitHub wiki:
2016-10-26 14:19:28 +02:00
2023-12-09 14:43:29 +01:00
* [Set up Build Environment on Linux ](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-Linux )
* [Set up Build Environment on Windows ](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-Windows )
* [Set up Build Environment on macOS ](https://github.com/keepassxreboot/keepassxc/wiki/Set-up-Build-Environment-on-macOS )
2016-10-26 14:19:28 +02:00
2024-06-24 07:43:59 -04:00
## Build Steps
2018-08-21 12:19:15 -04:00
We recommend using the release tool to perform builds, please read up-to-date instructions [on our wiki ](https://github.com/keepassxreboot/keepassxc/wiki/Building-KeePassXC#building-using-the-release-tool ).
2016-10-26 14:19:28 +02:00
2022-03-20 09:01:18 -04:00
To compile from source, open a **Terminal (Linux/MacOS)** , the **MSVC Tools Command Prompt (Windows)** , or **MSYS2-MinGW shell (Windows)** . For code development on Windows, you can use Visual Studio 2022, Visual Studio Code, or CLion.
2016-10-26 14:19:28 +02:00
2022-03-20 09:01:18 -04:00
1. Download the KeePassXC [source tarball ](https://keepassxc.org/download#source ) or check out the latest version from our [Git repository ](https://github.com/keepassxreboot/keepassxc ).
2017-11-26 16:36:46 -05:00
2022-03-20 09:01:18 -04:00
To clone the project from Git, `cd` to a suitable location and run
2017-11-26 16:36:46 -05:00
2022-03-20 09:01:18 -04:00
```
git clone https://github.com/keepassxreboot/keepassxc.git
```
2017-11-26 16:36:46 -05:00
2022-03-20 09:01:18 -04:00
This will clone the entire contents of the repository and check out the current `develop` branch.
2017-11-26 16:36:46 -05:00
2022-03-20 09:01:18 -04:00
To update the project from within the project's folder, you can run the following command:
2017-11-26 16:36:46 -05:00
2022-03-20 09:01:18 -04:00
```
git pull
```
2017-11-26 16:36:46 -05:00
2022-10-29 14:08:07 +02:00
For a stable build, it is recommended to check out the `latest` tag.
2018-03-18 01:10:00 +01:00
2022-03-20 09:01:18 -04:00
```
2022-09-11 14:38:53 +02:00
git checkout latest
2022-03-20 09:01:18 -04:00
```
2018-03-18 01:10:00 +01:00
2023-12-09 14:43:29 +01:00
2. Navigate to the directory where you have downloaded KeePassXC and run:
2021-09-06 22:26:00 -04:00
2022-03-20 09:01:18 -04:00
```
mkdir build
cd build
2024-06-24 07:43:59 -04:00
cmake ..
2022-03-20 09:01:18 -04:00
make
```
2024-06-24 07:43:59 -04:00
2023-12-09 14:43:29 +01:00
If you have `vcpkg` installed, add `-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake` to the `cmake` command to automatically download and install all required build and runtime dependencies locally to your build directory before compiling KeePassXC. Using `vcpkg` is the preferred way to install dependencies on macOS and required on Windows if using the MSVC toolchain.
2016-10-26 14:19:28 +02:00
2023-12-09 14:43:29 +01:00
For more detailed build instructions for each platform, please refer to the [GitHub wiki ](https://github.com/keepassxreboot/keepassxc/wiki/Building-KeePassXC ).
Note: These steps place the compiled KeePassXC binary inside the `./build/src/` directory (`src/KeePassXC.app/Contents/MacOS` on macOS).
2018-03-18 01:10:00 +01:00
2022-03-20 09:01:18 -04:00
## MacOS Build Notes
2018-08-21 12:19:15 -04:00
2024-03-15 19:35:26 -07:00
If you installed Qt@5 via Homebrew and CMake fails to find your Qt installation, you can specify it manually by adding the following parameter:
2016-10-26 14:19:28 +02:00
2024-03-15 19:35:26 -07:00
`-DCMAKE_PREFIX_PATH=$(brew --prefix qt@5)/lib/cmake`
2011-12-29 23:24:01 +01:00
2022-03-20 09:01:18 -04:00
When building with ASAN support on macOS, you need to use `export ASAN_OPTIONS=detect_leaks=0` before running the tests (LSAN is no supported on macOS).
2017-11-26 16:36:46 -05:00
2022-03-20 09:01:18 -04:00
## Windows Build Notes
2017-11-26 16:36:46 -05:00
2022-03-20 09:01:18 -04:00
If you are using MSYS2, you have to add ```-G "MSYS Makefiles"` `` at the beginning of the cmake command.
2023-12-09 14:43:29 +01:00
## Additional CMake Parameters
2017-11-26 16:36:46 -05:00
2024-06-24 07:43:59 -04:00
KeePassXC comes with a variety of build options that can turn on/off features. Each of these build options are supplied at the time of calling cmake:
2012-04-25 20:22:44 +02:00
2022-03-20 09:01:18 -04:00
```
2024-06-24 07:43:59 -04:00
-DKPXC_MINIMAL=[ON|OFF] Build KeePassXC with the minimal feature set required for basic usage (default: OFF)
-DKPXC_FEATURE_BROWSER=[ON|OFF] Browser integration and passkeys support (default: ON)
-DKPXC_FEATURE_SSHAGENT=[ON|OFF] SSH Agent integration (default: ON)
-DKPXC_FEATURE_FDOSECRETS=[ON|OFF] (Linux Only) freedesktop.org Secret Service integration; replace system keyring (default:ON)
-DKPXC_FEATURE_NETWORK=[ON|OFF] Include code that reaches out to external networks (e.g. downloading icons) (default: ON)
-DKPXC_FEATURE_UPDATES=[ON|OFF] Include automatic update checks; disable for managed distributions (requires networking) (default: ON)
-DKPXC_FEATURE_DOCS=[ON|OFF] Build offline documentation; requires asciidoctor tool (default: ON)
2022-03-20 09:01:18 -04:00
-DWITH_TESTS=[ON|OFF] Enable/Disable building of unit tests (default: ON)
-DWITH_GUI_TESTS=[ON|OFF] Enable/Disable building of GUI tests (default: OFF)
2024-06-24 07:43:59 -04:00
-DWITH_WARN_DEPRECATED=[ON|OFF] Development only: warn about deprecated methods, including Qt. (default: OFF)
2022-03-20 09:01:18 -04:00
-DWITH_ASAN=[ON|OFF] Enable/Disable address sanitizer checks (Linux / macOS only) (default: OFF)
-DWITH_COVERAGE=[ON|OFF] Enable/Disable coverage tests (GCC only) (default: OFF)
-DWITH_APP_BUNDLE=[ON|OFF] Enable Application Bundle for macOS (default: ON)
2024-06-24 07:43:59 -04:00
-DWITH_CCACHE=[ON|OFF] Use ccache for build speed optimization (default: OFF)
-DWITH_X11=[ON|OFF] Enable building with X11 dependencies (default: ON)
2022-03-20 09:01:18 -04:00
2024-06-24 07:43:59 -04:00
-DKEEPASSXC_BUILD_TYPE=[Snapshot|Release] Set the build type to show/hide stability warnings (default: "Snapshot")
-DKEEPASSXC_DIST_TYPE=[Snap|AppImage|Flatpak|Native] Specify the distribution method (default: "Native")
2022-03-20 09:01:18 -04:00
-DOVERRIDE_VERSION=[X.X.X] Specify a version number when building. Used with snapshot builds (default: "")
-DGIT_HEAD_OVERRIDE=[XXXXXXX] Specify the 7 digit git commit ref for this build. Used with distribution builds (default: "")
```
2011-12-29 23:24:01 +01:00
2024-06-24 07:43:59 -04:00
Note: Even though you can build the application with all TCP/IP networking code disabled, we still require and link against
Qt5's network library to use local named pipes on all operating systems.
## Installation
2016-10-26 14:19:28 +02:00
2017-11-26 16:36:46 -05:00
After you have successfully built KeePassXC, install the binary by executing the following:
2016-10-26 14:19:28 +02:00
```
2022-03-20 09:01:18 -04:00
sudo make install
2016-10-26 14:19:28 +02:00
```
2024-06-24 07:43:59 -04:00
## Packaging
2016-10-26 14:19:28 +02:00
2022-03-20 09:01:18 -04:00
You can create a package to redistribute KeePassXC (zip, deb, rpm, dmg, etc..). Refer to [keepassxc-packaging ](https://github.com/keepassxreboot/keepassxc-packaging ) for packaging scripts.
To package using CMake, run the following command using whichever [generators ](https://cmake.org/cmake/help/latest/manual/cpack-generators.7.html ) you would like to package with.
2016-10-26 14:19:28 +02:00
2022-03-20 09:01:18 -04:00
```
cpack -G "ZIP;WIX"
```
2016-10-26 14:19:28 +02:00
2024-06-24 07:43:59 -04:00
## Testing
2013-11-30 12:49:29 +01:00
2019-12-27 20:26:34 -05:00
You can perform tests on the built executables with:
2024-06-24 07:43:59 -04:00
2016-10-26 14:19:28 +02:00
```
2019-12-27 20:26:34 -05:00
make test ARGS+="--output-on-failure"
```
2022-03-20 09:01:18 -04:00
On Linux, if you are not currently running on an X Server or Wayland, run the tests as follows:
2024-06-24 07:43:59 -04:00
2019-12-27 20:26:34 -05:00
```
make test ARGS+="-E test\(cli\|gui\) --output-on-failure"
xvfb-run -e errors -a --server-args="-screen 0 1024x768x24" make test ARGS+="-R test\(cli\|gui\) --output-on-failure"
2016-10-26 14:19:28 +02:00
```
2012-05-28 12:11:44 +02:00
2016-10-26 14:19:28 +02:00
Common parameters:
2024-06-24 07:43:59 -04:00
2016-10-26 14:19:28 +02:00
```
CTEST_OUTPUT_ON_FAILURE=1
ARGS+=-jX
ARGS+="-E testgui"
```