Compiling Synergy for Raspbian

Although you can get Synergy through the package manager, it is an older version that may be incompatible with newer Synergy server versions. We are forced to compile Synergy ourselves to ensure that it is using the latest protocol and runs on Raspberry Pi's ARMv6 processor.
Download the source code tarball from Synergy's download page, it must be the .tar.gz file. Save it to /home/pi/downloads (make sure that folder exists first)
Alternatively, use wget through the terminal
Download: file
cd /home/pi/downloads
sudo wget http://synergy.googlecode.com/files/synergy-1.4.15-Source.tar.gz
Extract the tarball
Download: file
sudo tar -xzf synergy-1.4.15-Source.tar.gz
Raspbian does not come with some of the tools you might need, use the APT package manager to install the required tools. The following command will take some time and eat up some disk space.
Download: file
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install gcc cmake libx11-dev libxtst-dev
Navigate into the source code directory
Download: file
cd synergy-1.4.15-Source
Right now, what you should be doing is running cmake, which should generate a makefile. But at this point, cmake will fail with an error regarding not being able to find some header files. An error like "Missing header: X11/Xlib.hX11/XKBlib.h" might show up. This is because Synergy's CMakeList.txt file is looking for header files inside /usr/local/include , but in Raspbian, it should be looking inside /usr/include. We'll fix that by editing CMakeList.txt.
Download: file
sudo nano CMakeLists.txt
Use the nano text editor to look for the line
Download: file
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
and change it to
Download: file
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/include")
and close nano, the hot-key for closing nano should be CTRL-X

It will ask you to save before closing, you must save it
Inside the directory synergy-1.4.15-Source/tools , there is a zip file called cryptopp562.zip containing the Crypto++ library, which you must extract into the directory synergy-1.4.15-Source/tools/cryptopp562 , if you don't do this, you will eventually run into an error looking for the files inside. Do this from the terminal
Download: file
sudo unzip ./tools/cryptopp562.zip -d ./tools/cryptopp562
There's a bit of strangeness inside the synergy-1.4.15-Source/tools/CMakeList.txt file, it wants the C compiler to compile for the native architecture, but this will cause an error when the compiler doesn't understand what the word native means. We need to change this to ARMv6 since we are on a Raspberry Pi. Open the file using nano
Download: file
sudo nano ./tools/CMakeLists.txt
Look for the line
Download: file
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")

and edit it to the following on a Pi 1

Download: file
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv6zk")

for the Pi 2, do this instead:

Download: file
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a")
and close nano, the hot-key for closing nano should be CTRL-X

It will ask you to save before closing, you must save it
We have now done all of the steps to preemptively prevent the errors you will face.

Now we can use cmake to configure our makefile build
Download: file
sudo cmake .
This will take a while... grab a coffee. After it finishes, it should say:
Download: file
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/download/synergy-1.4.15-Source
What it did was check over your system to see if you have all of the required files, and see what kind of tools are available. It uses this information to generate a makefile for you.

Now you can use make to build the source code according to the makefile
Download: file
sudo make
This time, nuke some popcorn and watch a movie, this literally took a few hours. Nobody claimed that the 700MHz Raspberry Pi was very fast.

When it finishes with no errors, a new directory at synergy-1.4.15-Source/bin should exist, and inside should be several executables files. Install these by using the copy command to copy the files into the /usr/bin directory
Download: file
sudo cp -a ./bin/. /usr/bin
This guide was first published on Dec 11, 2013. It was last updated on Dec 11, 2013. This page (Compiling Synergy for Raspbian) was last updated on Apr 02, 2020.