在win10和centos7上編譯synergy
Synergy功能簡介
同一區域網路中多台機器共享一套鍵盤滑鼠,支援Windows、Linux、MAC裝置,滑鼠鍵盤實體連接配接的機器做伺服器端,其他機器做用戶端程式,在伺服器端對各台機器進行簡單配置,在用戶端輸入伺服器端IP位址或網絡名,即可體驗其強大功能。
準備工作
1,擷取Synergy源碼
git clone https://github.com/symless/synergy-core.git
2,安裝win10上需要的工具
1, Install Git for Windows
2, Install Visual Studio Professional 2015 with Updates
a, Select Custom
b, Deselect all
c, Within
Programming Languages
, select
Visual C++
d, Git for Windows should already be installed
3, Download the Windows 10 SDK Web Installer
a, Click
Download the installer
(not the iso)
b, Use default options for first 2 screens
c, On the feature screen, untick everything except
Debugging Tools for Windows
4, Install Bonjour
a, Download: Bonjour SDK for Windows v3.0
5, Install Qt
a, Install to C:\Qt
b, Select Qt 5.9.5
6, Add ‘C:\Qt\Tools\QtCreator\bin’ to the system PATH
7, Install CMake
a, Add CMake to PATH for all users
8, Restart Qt
9, Set
CMAKE_PREFIX_PATH
environment variable to
\path\to\qt\qt_version\msvc2015_64
10, Now follow the compile steps below
3,安裝cento7上需要的工具
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
編譯
1, win10 上編譯
1,将源碼位置配置到CMake中:配置源碼目錄和編譯目錄,一般都是在源碼目錄下建立一個build目錄來進行編譯。
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNvwVZ2x2bzNXak9CX90TQNNkRrFlQKBTSvwFbslmZvwFMwQzLcVmepNHdu9mZvwFVywUNMZTY18CX052bm9CXykEROJTSU9ENjRVTxh2MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2LcRHelR3LcJzLctmch1mclRXY39DO2gTNxQTMzIjNxATM4EDMy8CX0Vmbu4GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.jpg)
2,執行Configure,選擇合适的編譯器,然後點Finish。
之後會進行配置,完成之後會出現如下界面:
3,點選Generate,生成項目檔案
4,在上面我們配置的編譯目錄
E:\synergy-core\build
就會看到已經生成vs2015的工程檔案:
直接輕按兩下打開synergy-core.sln檔案進行編譯,不出意外一般都會成功:
2,centos7上編譯
cd Projects/synergy
mkdir build
cd build
cmake ..
make
配置使用
synergy配置很簡單,其說明文檔也比較清楚,我隻有兩台電腦,一個筆記本win10,一個桌上型電腦centos7,桌上型電腦公用筆記本的鍵盤滑鼠,我的配置檔案如下:
# sample synergy configuration file
#
# comments begin with the # character and continue to the end of
# line. comments may appear anywhere the syntax permits.
section: screens
# three hosts, named "moe", "larry", and "curly"
laptop:
centos:
end
section: links
# for moe, larry is to the right and curly is above.
laptop:
right = centos
# for larry, moe is to the left and curly is also above.
# note that curly is above both moe and larry
# and that the connection between moe and larry is symmetric
# (i.e. they're in opposite directions of each other).
centos:
left = laptop
end
section: aliases
# curly is also known as shemp
laptop:
james-laptop
centos:
james-centos
end
在win10上以管理者身份運作cmd,進入到編譯環境下執行:
synergy-core.exe --server --config synergy.conf
在centos7上以root身份運作如下指令即可:
sudo ./synergy-core --client 192.168.10.104
其中
192.168.10.104
為win10的ip位址。然後就可以通過一個鍵盤一個滑鼠控制兩個電腦了。
我是在win10上寫了一個簡單的批處理來直接輕按兩下打開可以參考:
@ echo off
echo 正在啟用超級管理者權限...
%1 %2
ver|find "5.">nul&&goto :st
mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :st","","runas",1)(window.close)&goto :eof
:st
copy "%~0" "%windir%\system32\"
echo 啟用超級管理者權限成功
cd /d D:\Program Files\synergy
"synergy-core.exe" --server --config synergy.conf