Compiling Synergy from source on the Raspberry Pi

Recently I set up my Raspberry Pi and the first thing I wanted to do to make it usable was to get Synergy working. Synergy is a program which you can use to essentially connect two computers together so that you can interact with both using just one keyboard and mouse.

I’ve previously used Synergy on x86_64 based operating systems without problems, but never on ARM – which involved compiling Synergy from source. As I had a few problems along the way to solve I figured this post would be useful for people going through the same process.

I will be running Synergy in this example as a client, as I have the server instance installed and running on my primary desktop computer. The Synergy server is sitting there listening for connections on my local network, and once the Synergy client is up and running on the Raspberry Pi the connection will be established and I’ll be able to use the keyboard and mouse on my desktop to access the Raspberry Pi.

If you’re interested in the Raspberry Pi you can look at various kits available here on Amazon, they are useful as they come with loads of accessories so you don’t have to try and buy all of the bits and pieces from all over the place.

Compiling Synergy on the Raspberry Pi – ARM architecture

While Synergy provides various packages ready to install on all sorts of operating systems, it does not appear that there was anything available for the ARM architecture which meant I’ve compiled and installed Synergy on my Raspberry Pi from the source code provided. My Raspberry Pi is running the Raspbeian OS and this is more or less Debian wheezy.

First off I downloaded the current version of Synergy using wget on the Raspberry Pi from the Synergy downloads page and then extracted the tar file.

wget http://synergy.googlecode.com/files/synergy-1.4.10-Source.tar.gz
tar xf synergy-1.4.10-Source.tar.gz
cd synergy-1.4.10-Source/

There is a configure script in this directory, so I attempted to run that only to find that cmake was not installed, so with a quick apt-get install cmake I was ready to continue.

./configure
...
./configure: line 1: cmake: command not found
apt-get install cmake

Alright so cmake is installed and ready to go, time to try the configure script again.

./configure
...
CMake Error at CMakeLists.txt:196 (message):
  Missing header: X11/Xlib.hX11/XKBlib.h
-- Configuring incomplete, errors occurred!

This is saying that we are missing some header files that are required for Synergy, so I install the necessary package and try configure again.

apt-get install libx11-dev
./configure
...
CMake Error at CMakeLists.txt:196 (message):
  Missing header: X11/Xlib.hX11/XKBlib.h
-- Configuring incomplete, errors occurred!

Hmm, still erroring so let’s take a look at line 196 of this CMakeLists.txt file and see what it’s after.

if (NOT HAVE_X11_XKBLIB_H)
  message(FATAL_ERROR "Missing header: " ${XKBlib})
endif()

But we just installed the package for that? Yes, that’s correct however my installation went to /usr/include/X11/ – if you search through the CMakeLists.txt file for the first instance of “X11” you will find the following section that defines a specific path.

# add include dir for bsd (posix uses /usr/include/)
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
set(XKBlib "X11/Xlib.h;X11/XKBlib.h")

You can see here that the path defined is /usr/local/include/ however our X11 contents have been placed into /usr/include/ – as is explained in the commented out line.

Simply edit the .txt file with your favourite text editor and remove the “local/” part of the path and then save the file. Since originally writing this guide, I have not needed to do this with the current bersions of Synergy and Raspbian so you may not encounter this any more.

When I ran ./configure at this point, I was still getting the exact same error which seemed strange. I noticed that in the same directory the last time I ran ./configure it had created a cached file in CMakeCache.txt, so I tried simply renaming this and then running configure again which worked.

mv CMakeCache.txt OldCache.txt
./configure
...
CMake Error at CMakeLists.txt:222 (message):
  Missing library: Xtst
-- Configuring incomplete, errors occurred!

This is another easy one to fix, simply install the libxtst package and then run configure again.

apt-get install libxtst-dev
./configure
...
-- Build files have been written to: /home/pi/synergy-1.4.10-Source

Almost at the end now, the configure script completed without any issues so let’s run make.

make

This took quite a while to complete on the Raspberry Pi, however it completed for me with no errors. The important files that you would want to run to either set Synergy up as a client or server are located in /bin within your installation directory, you will have files synergyc for running a client instance, and synergys for the server.

Running Synergy as a client

To do this I just executed the synergyc file in /bin with the following command.

./synergyc --daemon --name Pi --restart 192.168.0.1

That’s it, Synergy is running as a daemon in the background as a client, it is named “Pi”, it will automatically restart if it crashes for what ever reason and it will connect to the IP specified . In this case this is the IP of my primary desktop as this is already running Synergy as a server.

You can run ./synergyc --help to get information on the options you can run.

Making Synergy start automatically on boot

In order to get Synergy to automatically start up I’ve made the file /etc/init.d/synergy which contains the content below.

#!/bin/sh
#/etc/init.d/synergy
case "$1" in
  start)
    cd /home/pi/synergy-1.4.10-Source/bin/
    su pi -c './synergyc --daemon --name Pi --restart 192.168.0.1'
    echo "Starting synergy client..."
    ;;
  stop)
    pkill synergyc
    echo "Attempting to kill synergy client"
    ;;
  *)
    echo "Usage: /etc/init.d/synergy (start/stop)"
    exit 1
    ;;
esac
exit 0

Once this file has been created, set the permissions on it so that it can be executed correctly.

sudo chmod 755 /etc/init.d/synergy

It’s a little dodgy, but it gets the basic job done. Once this was complete I ran the following command to ensure that it would run with everything else.

update-rc.d synergy defaults

update-rc.d: using dependency based boot sequencing
insserv: warning: script 'K01synergy' missing LSB tags and overrides
insserv: warning: script 'synergy' missing LSB tags and overrides

You can basically ignore these warnings, it will still work – or you can add in the LSB tags to the /etc/init.d/synergy file and run update-rc.d again.

You’d then want to run the following:

insserv synergy

You should then be able to run the following commands to start and stop the synergy client.

/etc/init.d/synergy start
/etc/init.d/synergy stop

Summary

That’s it, after a reboot to test synergy was up and running – I was able to move my mouse from the desktop monitor to the monitor the Raspberry Pi was plugged into and interact with it. I did notice that every few hours or so (I typically come back to my Pi after 24 hours) that synergyc would be using a fair amount of CPU, as viewed in top. I simply ran the below command to stop and then start synergy. It is important to do both in the same command line otherwise you may find yourself stuck on the primary computer until you plug in a keyboard to the Raspberry Pi.

service synergy stop; service synergy start
Leave a comment ?

66 Comments.

  1. Unboxing and setting up the Raspberry Pi | Root Users - pingback on August 27, 2012 at 7:14 pm
  2. Great tutorial!

    Shame about the bad value in CMAKE_INCLUDE_PATH — this was added in a patch for BSD but looks like some Linux distros were affected (like Raspbian OS).

    I raised this bug:

    http://synergy-foss.org/spit/issues/details/3365/

    • Thanks. :)

      That’s great, it took me a little while to get to the bottom of that issue, hopefully the work around will help others in the mean time.

  3. Thanks a lot!

    I don’t have any experience in linux, but I could follow your tutorial perfectly.

    It worked like a charm!

  4. Thanks for the tutorial:)
    I’m still learning the ropes when it comes to using linux so please bear with me.
    Following your instructions I successfully compiled the source but when I run the synergyc –daemon –name Pi –restart 192.168.0.3 it just displays INFO: Synergy 1.4.10 Client on linux etc.. and doesn’t try to connect to the server. However if I run it from within x with the –no-daemon flag it starts and connects fine.
    Also could you please elaborate on setting synergy to run at boot as I just don’t get your instructions on making the /etc/init.d/synergy file.
    Any suggestions appreciated :)

    • No problem, glad I could help.

      Did you test running Synergy as root? You may need to run the client with other options to get it working, try synergyc –help to see details on all the flags. I’m not an expert with Synergy (just yet) so you may have better luck asking here.

      When you say you are running without x originally is that with no GUI? Synergy is a GUI tool so I’d imagine that’s required.

      Are you sure Synergy is listening on the other computer acting as the server? Is there any firewalls running on either computer? You can run netstat on the server computer to confirm that Synergy is listening for connections.

      As for starting on boot, I basically just made the /etc/init.d/synergy file you see above in the post, and then ran “update-rc.d synergy defaults”. Alternatively do a search for how to get services to start on boot for your particular operating system.

      • I’m able to make the synergy file in /etc/init.d but when i execute update-rc.d synergy defaults

        it returns

        update-rc.d: using dependency based boot sequencing
        insserv: script synergy is not an executable regular file, skipped!

        How can I fix this please? Thanks in advance

    • Hi. Maybe for some users like me thats not clear enough… I found the solution. Problem is, that you never used (like me) the graphical environment and maybe only ssh. just type in console: sudo raspi-config and there is an option to set that raspi boots directly into desktop environment. Set up that synergy starts directly upon boot like described above or start synergy in console and you can use your raspi without any extra-keyboard. Thats nice! Thanks to the above guide!

  5. Had a quick issue: after getting all the needed packages and clearing the cache (renaming), I tried to run configure again but got the following error:

    CMake Error at src/test/CMakeLists.txt:23 (add_library):
    Cannot find source file:

    ../../tools/gmock-1.6.0/src/gmock-all.cc

    Any ideas?

    Thanks!

  6. Can you post the compiled version for use?

    • That’s not practical sorry, you’ll need to compile it yourself from source for it to work on your set up.

      • How come it needs to be compiled specifically for my setup? I have raspbian and I’ve installed tons of stuff through apt-get and they all work fine. What would make it impossible to create a package for synergy?

        • Nothing, when I went through the install process there was no package available so source was my only option.

  7. Compiled/made just fine.
    But when I try to run “synergyc” (and anything after it), I get an error of synergyc: command not found… it’s in the /bin directory, I can see it via the gui…

    Thanks!

    • Have you tried using the full path? So /bin/synergyc ? You can try running something like “whereis synergyc”, my output pointed me to /usr/bin so I can bring up the help by running /usr/bin/synergyc –help

    • I also had this problem. Issuing the synergyc command didn’t work right away.
      I found that “./synergyc” worked (while being inside the bin directory)

      • I have gone through this process since on a new Raspberry Pi and also had to use ./ for synergyc in my script, I’ll edit the post now to reflect this.

  8. Great tutorial, thanks. Now I can get rid of a keyboard and mouse from my desktop. :)

    Is it possible to build a package (deb, I presume) out of this for Raspbian that we could simply install in the future without the need for compiling?

    I find that synergy is a must have for RPi and it’s quite sad that I have to go through all of this each time I change the OS image (for testing purposes). I know there is an older version of synergy readily available in aptitude, but I find this newer version much better, especially for the improvements in the Windows version.

  9. Just a note, I also had to install libxtst-dev on my Pi to get needed headers to get Synergy to build.

  10. I’m still getting the error

    CMake error at CMakeLists.txt:222 (message)
    Missing library: Xtst

    I just installed that.

  11. You might want to add details on making the start-up script executable.

    sudo chmod 755 /etc/init.d/synergy

    The above command should be ran before running the “update-rc.d synergy defaults” command, which, I had to run with sudo otherwise I received a permission denied error.

    • Correct, I had to do this too the other day when I reinstalled my OS again after the SD card became corrupt. :(

      I’ll add in this step now.

  12. Thank you for your guide, I’m having a bit of trouble though. I have set up synergy on my windows 7 PC and my new rpi, and the log shows that the rpi connects fine. I can move the cursor off of my windows screen, but there’s no control transferred to my rpi. Do you know if there’s something I’ve missed?

    • Hey Mark,

      I had a similar issue recently when I went through this process again. On the Windows PC that you have Synergy set up as a server have you tried enabling a higher level of logging?

      Depending on your version you should be able to right click Synergy and select the logging level and view log, or click show to view the log. This should let you know if there are any issues on the server end, and should show if the client is actually connecting and if it is disconnecting etc.

      On the client side you can run ./synergyc -l /var/log/synergy.log for example along with the rest of the information to connect to the server, any issues should get logged into the defined file so you can check that as well.

      • On the windows side, there’s logs of screen exits and entrances, mouse inputs etc., everything seems normal. My log from the rpi just has

        ERROR: dup error: 2

        repeated seven times, even if I set the logging level to debug2. Googling the error didn’t give me much.

        What was the issue you had and how did you manage to resolve it?

        • I did have this in my most recent round of Synergy compilation on the latest version of Raspbian – I had never previously had this issue until last week.

          I was seeing the client connecting and disconnecting repeatedly on the server, with dup error 2 on the client logs. At first I thought there was something funny with my network settings but this was not the case.

          To be honest I am not sure exactly what I did to fix the error. I recall almost running out of options so I removed Synergy on the Windows side I had running for a long time as the server and then installed the latest version as I was running an older one, and since then everything basically worked.

          I played around with things like ensuring –name on the client was set to the same name on the server etc (as this was not the case) and more, but the command in the end I ended up using was the same one in my original post which is in /etc/init.d/synergy so I can only assume upgrading the server side fixed this for me.

  13. Very good instructions! I followed them almost exactly and got Synergy compiled. I needed a few hints from elsewhere to get it to work with my Win7 server. But the compilation! You say “This took quite a while to complete on the Raspberry Pi”. Yeah, over half an hour! Would it violate the license (or machine-specific dependencies?) for somebody to post the binaries? It would save a lot of downloading, apt-getting, configuring, and a looooong compile. (I didn’t try overclocking — maybe this would be a good test.) But it is working, and I don’t think I could have done it without you, so thanks!

  14. Great instructions.

    I have a 3 box, 4 screen set-up. Win XP, Win7, and now Raspi. Synergy has been running on my XP and Win7 for a couple of years already.

    Synergy installed on my model B fine. However mouse arrow did not transfer over from my Win7 server screens to Raspi. Observing the realtime “chat” on my network with WireShark revealed that the Raspi was trying to find the server [Win7]. I had also used the no-daemon option in my tests. After a day I finally went into the server config file and found the server was not using the Synergy config file re-wrote to include the Raspi. A typo for the Raspi screen “Pi” was supposed to be “pi” then it all worked as planned !

    So, my advice is make sure the names in the server are exactly the same for server and client and perhaps for some of us, using the no-daemon option. I also use my own Synergy config file so I have some visual control of the server as well.

    Don’t be alarmed if for whatever reason, Synergy copies your config file to a “temp” location and logs that instead. Comparing both files reveals they are the same. No worries. Just compare them and make sure both files are the same.

    Now the Raspi is able to use the same mouse across 3 different OS’s and I’m happy there are no conflicts with NetBeans running YAGARTO on the XP and WinSCP on XP accessing files on Raspi running SAMBA. Next I’ll add the Zotac ZBox and a 4th OS to my network.

    Woo hoo ! The hardware development life !

  15. Thank you!

  16. Simpler, just a bit.
    sudo su
    apt-get update && apt-get upgrade -y && apt-get install -y cmake libx11-dev libxtst-dev

    then ./configure
    make

    will have to see what make install does…

  17. If you get this error..

    Linking CXX executable ../../../bin/synergyc
    /usr/bin/ld.gold.real: error: ../../../lib/libcryptopp.a(test.o): multiple definition of 'main'
    /usr/bin/ld.gold.real: CMakeFiles/synergyc.dir/synergyc.o: previous definition here
    collect2: ld returned 1 exit status
    make[2]: *** [bin/synergyc] Error 1
    make[1]: *** [src/cmd/synergyc/CMakeFiles/synergyc.dir/all] Error 2
    make: *** [all] Error 2

    this is the fix (add test.cpp to ignore tools/CMakeLists.txt)

    ~/src/synergy/tools
    file(GLOB cpp_ignore
    ${cpp_dir}/simple.cpp
    ...
    ${cpp_dir}/test.cpp
    ${cpp_dir}/algebra.cpp)

  18. First thanks, really helped me alot.
    But i still have a problem using the script.
    it wont start synergy while booting.
    I’ve to open a terminal and enter “service start synergy” to start the client, an i’ve also to enter the password for user pi

    i let the script create and delete an folder upon start/stop to test if the script is called at booting, works just fine, so i think the problem is that he wants the passwort after the “su pi -c…”

    • ok got a little workarround
      i created a new script

      #!/bin/bash
      sudo service synergy start

      then added it to /etc/rc.local

      cd //
      ./home/pi/script

  19. I’m having a problem while compiling for RPi:
    [ 11%] Building CXX object tools/CMakeFiles/cryptopp.dir/cryptopp562/files.o
    Assembler messages:
    Error: unknown architecture `native’

    Error: unrecognized option -march=native
    cc1plus: error: bad value (native) for -march switch
    make[2]: *** [tools/CMakeFiles/cryptopp.dir/cryptopp562/files.o] Error 1
    make[1]: *** [tools/CMakeFiles/cryptopp.dir/all] Error 2
    make: *** [all] Error 2

    • Hi Makarons,

      I haven’t personally had this error, so hopefully someone else may be able to help here.

      Were you running this as the root user? Are you able to use compile with a different architecture?

    • I had the same problem as well, I think it has to do with the encryption that was implemented in 1.4.12. I tried again with 1.4.10 and was able to compile fine. Hopefully this helps somebody!

  20. Hey, I’m having trouble getting the configure to work still :evil:
    When I try and configure I’m given the following error:
    CMake Error at tools/CmakeLists.txt:32 (list):
    list sub-command REMOVE_ITEM requires two or more arguments.

    Do you know how to fix it or have any advice? I tried commenting out the line to fix it(not my brightest idea hah) and it let me configure with errors, but the make had fatal errors and stopped the make.

    Thanks, Josh

  21. Hi
    When I attemp to start synergy in the command
    /etc/init.d/synergy start
    The terminal tells me that the file doesent exist yet I copied everything into the directory, could it be the insserv command as it wouldn’t run properly,
    Thanks :razz:

  22. Using the source of version 1.4.10 did the trick for me.

  23. After installing libxtst-dev and trying to configure I get the following error message.

    CMake Error at CMakeLists.txt:223 (message):
    Missing library: Xtst

    Does anyone have any suggestions?

    • I hit that one too – it is the equiv of the config cache file. If you are using the /.hm.sh to compile, it puts the junk in the ../build directory. You can safely blow that away and rerun the ./hm.sh script

  24. So, when you compiled, about 20% of the way in, you didn’t hit “Error: Unknown architecture ‘native’?”

    Bad value for the -march switch?

    Maybe it is a new bug in the 1.4.15 release. I don’t have time right now to grind though what it should be but if someone else has hit this and has a fix that would be great to know.

    • Never mind – Charles answered it above.

      edit tools/CMakeLists.txt
      replace
      -march=native
      with
      -march=armv6zk

      That fixed it…grumble…thanks all.

      • If you follow this guide for a different platform like Radxa Rock Quadcore RK3188, arm-linux-gnueabihf-gcc 4.8.2 claims that some bitmangling functions are not supported with this platform.
        So you shoudl replace it with
        -march=armv7-a
        and it works absolutely fine.

  25. When I ran

    sudo apt-get install libxtst-dev

    I get the message

    E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?

  26. :razz:
    Greate document!!
    mv CMakeCache.txt OldCache.txt is key to me!!
    Thanks.
    \

  27. This worked wonderfully even for version 1.5.0. :razz:

  28. CMake Error at CMakeLists.txt:242 (message):
    Missing library: Xtst

    I just installed the libXtst-dev… I think my question has been answered by DavidL, however, I don’t even know what ‘compile’ actually means, just following the instructions :mrgreen: so detailed instructions what I have to do to fix this like “mv CMakeCache.txt OldCache.txt” would be great :) thanks in advance

  29. Great tutorial thanks

  30. Raspberry Pi 2 user here so a few updates I found past the above instructions (which were awesome for a noob like me to linux) THANKYOU

    The source is now found at gitHub
    https://github.com/synergy/synergy/archive/master.zip

    A shortcut I found to having to install each package as you stumble through .configur commands error halting would be to use the Ubuntu dependencies instructions from the Synergy wiki instructions


    sudo apt-get install cmake make g++ xorg-dev libqt4-dev libcurl4-openssl-dev libavahi-compat-libdnssd-dev

    After the above instructions I had issues with

    CMake Error at src/test/CMakeLists.txt:23 (add_library):
    Cannot find source file:
    ../../tools/gmock-1.6.0/src/gmock-all.cc
    </blockquote
    I found 3 zip files in the ext directory. I extracted each into their own folder with the same name e.g.

    cd ext
    unzip cryptopp562.zip -d ./cryptopp562

    after I did this I could make … it was slow which while mot unexpected for a Pi – I noticed it was using only 25% CPU max .. hrm Raspberry Pi 2 is quad core .. I found the following command that allows make to run multi threaded

    make -j 4

    ( RaspberryPi 2 B has 4 cores)

    NOTE: can’t see a preview – hope I can edit this afterwards if I mess up formatting.

    • Hey Jamie, thanks for the steps around the changes, I have a Raspberry Pi 2 in the mail so hopefully once I get it I can either update the post or create a new one specifically for the new version, we’ll see. :razz:

    • I know this is an old thread, but this advice really helped me a lot! Thank you, Jamie. I wish you had clones on the numerous other pages I visit for help!

  31. Only person on the internet who knows how to fix this issue is here.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Trackbacks and Pingbacks: