Skip to content

Compiling

Nick Bolton edited this page Jan 12, 2024 · 101 revisions

Important: Follow the Getting Started guide first to get the code. Before you can compile, you'll need the source code. Ensure you checkout the appropriate branch you wish to compile, e.g. if you wish to compile v1.13.1, git checkout v1.13.1.

Also, this guide is for compiling Synergy Core v1.9 and up (including v2.0). If using v1.3.5 to v1.8, follow the Compiling Legacy guide.

Table of Contents

Dependencies

Windows

  1. Install Git for Windows
  2. Install Visual Studio Community 2019 with Updates
    1. Select Custom
    2. Deselect all
    3. Within Programming Languages, select Visual C++
    4. Git for Windows should already be installed
  3. Install Windows 10 SDK
    1. Select Download the installer, not the iso
    2. Use default options for first 2 screens
    3. On the feature screen, unselect everything except Debugging Tools for Windows
  4. Install Bonjour SDK for Windows v3.0
  5. Install Qt (latest version; not Qt 5)
    1. Install to C:\Qt
    2. Select 'Custom installation'
    3. Expand 'Qt'
    4. Select 'Qt 5.x.x' (e.g. 5.15.2)
    5. After installation, add C:\Qt\5.15.2\msvc2019_64\bin to the system PATH
  6. Install OpenSSL either directly or with Chocolatey
    1. Remove(if exist) old OpenSSL from PATH in environment variables
    2. Remove(if exist) old OpenSSL folder from C:\Program Files\ and C:\Program Files (x86)
    3. Install new OpenSSL either directly or with Chocolatey
      1. choco install openssl
  7. Install CMake
    1. When prompted for PATH, select one of the options starting with "Add CMake to system PATH …"
  8. Restart Qt
  9. Set CMAKE_PREFIX_PATH environment variable C:\Qt\5.12.12\msvc2017_64
  10. Follow the compile steps below

macOS

  1. Install Homebrew
  2. Install XCode (also available via the Mac App Store)
  3. Install OpenSSL
    1. brew install openssl
  4. Install Qt:
    • Brew:
      1. brew install qt@5
      2. export CMAKE_PREFIX_PATH="$(brew --prefix qt5)"
    • Online installer (latest version; not Qt 5)
      1. Select 'Custom installation'
      2. Expand 'Qt'
      3. Select 'Qt 5.x.x' (e.g. 5.15.2)
  5. Now follow the compile steps below

Linux

Ubuntu 16.04 and up

sudo apt install -y \
  qtcreator \
  qtbase5-dev \
  qttools5-dev \
  cmake \
  make \
  g++ \
  xorg-dev \
  libssl-dev \
  libx11-dev \
  libsodium-dev \
  libgl1-mesa-glx \
  libegl1-mesa \
  libcurl4-openssl-dev \
  libavahi-compat-libdnssd-dev \
  qtdeclarative5-dev \
  libqt5svg5-dev \
  libsystemd-dev \
  libnotify-dev \
  libgdk-pixbuf2.0-dev \
  libglib2.0-dev

Edit the Qt kit "Environment" field under Tools -> Options -> Build & Run -> Kits and add BOOST_ROOT=/home/<user>/boost

CentOS 7

sudo yum groupinstall "Development Tools"
sudo yum -y install epel-release cmake3 boost-static git libXtst-devel qt5-qtbase-devel qt5-qtdeclarative-devel libcurl-devel openssl-devel

Fedora 28 (may work for earlier releases)

sudo yum groupinstall "Development Tools"
sudo yum -y install avahi-compat-libdns_sd-devel avahi-compat-libdns_sd cmake3 boost-static git libXtst-devel qt5-qtbase-devel qt5-qtdeclarative-devel libcurl-devel openssl-devel

SUSE Linux 12 SP3

sudo zypper install avahi-compat-mDNSResponder-devel libavahi-devel libqt5-qtbase-devel cmake libopenssl-devel libcurl-devel libXtst-devel

Compile Steps

Make sure you have completed the steps at Getting Started.

IDE Compile

Compile instructions for Qt Creator.

macOS

Do this first on macOS.

  1. Qt Creator > Preferences > Kits > CMake
  2. Click Add, set Path to: /usr/local/bin/cmake
  3. Go to the Kits tab
  4. Set the C compiler to Clang 64-bit
  5. Restart Qt Creator

Note: this may already be pre-configured for you.

All OSes

  1. Open Qt Creator
  2. If macOS, follow macOS Only steps
  3. Open Project
    1. Ctrl + O or File->Open File or Project
    2. Navigate to the project directory (from git clone)
    3. Open CMakeLists.txt
  4. Untick "Imported Kit"
  5. Expand "Desktop Qt 5.12.12 MSVC{VS version} {Prefered configuration}" e.g. Desktop Qt 5.12.12 MSVC2015 64bit
  6. Untick all except Debug and Release and click Configure
  7. Right-click on project and select Run CMake
  8. If macOS, follow macOS Post-CMake steps
  9. Build
    1. Check that selected mode is Release(bottom-left corner in QT CReator)
    2. Right-click project and select Build

macOS Post-CMake

  1. Open Projects
  2. Select Build
  3. Find CMAKE_OSX_DEPLOYMENT_TARGET
  4. Set value to your version of OSX, e.g. 10.10, 10.13, etc. If you do not match the version of the OS SDK libraries you are linking against, there will be a lot of warnings during the build. By using the correct version, you will only receive deprecation warnings.
  5. Find CMAKE_OSX_SYSROOT
  6. Set value to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/
  7. Click Apply Configuration Changes
  8. Go back to the All OSes steps (above)

GUI standalone in Windows

These steps apply to 64-bit compilations.

In release and debug mode:

  1. Copy all contents of synergy-core/ext/openssl/windows/x64/bin/* to {build_folder}/bin/
  2. Copy the following files from {QtInstallDir}/{QT Version}/{Compiler version}/bin/(e.g. C:\Qt\5.12.12\msvc2015_64) to {build_folder}/bin/:
    • Qt5Core.dll
    • Qt5Gui.dll
    • Qt5Network.dll
    • Qt5Widgets.dll
  3. Create folder platforms under {build_folder}/bin/
  4. Copy {QtInstallDir}/{Version}/MSVC2019_64bit/plugins/platforms/qwindows.dll in to {build_folder}/bin/platforms

To make possible debugging:

  1. Copy all the files requested in release mode
  2. Also from Qt installation directory, copy the following files (pay attention to the letter d in file names):
    • Qt5Cored.dll
    • Qt5Guid.dll
    • Qt5Networkd.dll
    • Qt5Widgetsd.dll

CLI Compile

Compiling from the command line.

Windows

cd synergy-core
mkdir build
cd build
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat"
cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Debug ..
msbuild synergy-core.sln /p:Platform="x64" /p:Configuration=Debug /m
cd ..
copy ext\openssl\windows\x64\bin\* build\

Example

  • QT version is 5.12.12, and is installed at 'C:\Qt\5.12.12'
  • Windows 10 SDK version is 10.0.19041.0
  • Open C:\Program Files (x86)\Windows Kits\10\SDKManifest.xml
  • Find 'PlatformIdentity = "UAP, Version=10.0.19041.0"'
  • Visual studio 2019 community
  • Your source path is "c:<path>\synergy-core"
  • Your host is x64
  • Will build as x64 binary
cd "c:\<path>\synergy-core"
mkdir build
cd build
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 10.0.19041.0
cmake -G "Visual Studio 16 2019"  -DCMAKE_BUILD_TYPE=Debug ..
msbuild synergy-core.sln /p:Platform="x64" /p:Configuration=Debug /m
cd ..
copy ext\openssl\windows\x64\bin\* build\

If you want to build the MSI package, see Building the MSI Installer for details.

macOS

cd synergy-core
mkdir build
cd build
export  QT_PATH=$HOME/Qt/<qt version> ("ex:export  QT_PATH=/Users/user/Qt5.12.12/5.12.12/clang_64")
export PATH=$PATH:/usr/local/bin:$QT_PATH/bin
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE ..
make

Go to build folder > bin copy all execs and place in bundler > Synergy.app (click left and Show package contents) > Contents and make a folder called MacOS and paste the execs there

Linux

cd synergy-core
mkdir build
cd build
cmake ..
make