This page describes the process of building a ModbusTools project from source files.
The ModbusTools project requires Qt version 5.8 or later.
-
Update package list:
$ sudo apt-get update -
Install main build tools like g++, make etc:
$ sudo apt-get install build-essential -
Install Qt tools:
$ sudo apt-get install qtbase5-dev qttools5-dev -
Check for correct instalation:
$ whereis qmake qmake: /usr/bin/qmake $ whereis libQt5Core* libQt5Core.prl: /usr/lib/x86_64-linux-gnu/libQt5Core.prl libQt5Core.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so libQt5Core.so.5: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 libQt5Core.so.5.15: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15 libQt5Core.so.5.15.3: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3 $ whereis libQt5Help* libQt5Help.prl: /usr/lib/x86_64-linux-gnu/libQt5Help.prl libQt5Help.so: /usr/lib/x86_64-linux-gnu/libQt5Help.so libQt5Help.so.5: /usr/lib/x86_64-linux-gnu/libQt5Help.so.5 libQt5Help.so.5.15: /usr/lib/x86_64-linux-gnu/libQt5Help.so.5.15 libQt5Help.so.5.15.3: /usr/lib/x86_64-linux-gnu/libQt5Help.so.5.15.3
-
Install git:
$ sudo apt-get install git -
Create project directory, move to it and clone repository:
$ cd ~ $ mkdir src $ cd src $ git clone --recursive https://github.com/serhmarch/ModbusTools.git
-
Create and/or move to directory for build output, e.g.
~/bin/ModbusTools:$ cd ~ $ mkdir -p bin/ModbusTools $ cd bin/ModbusTools
-
Run cmake to generate project (make) files.
$ cmake -S ~/src/ModbusTools -B . -
Make binaries (+ debug|release config):
$ cmake --build . $ cmake --build . --config Debug $ cmake --build . --config Release
-
Resulting bin files is located in
./bindirectory.
cmake --preset "Linux-Debug"
cmake --build --preset "Linux-Debug"
cmake --preset "Linux-Release"
cmake --build --preset "Linux-Release"To install compiled binaries and other necessary files run next command:
$ cmake --install <build_dir> --prefix <install_dest_dir>Next command installs files from build dir into ModbusTools dir of user's home directory:
$ cmake --install . --prefix "$HOME/ModbusTools"-
Run qmake to create Makefile for build:
$ qmake ~/src/ModbusTools/src/ModbusTools.pro -spec linux-g++ -
To ensure Makefile was created print:
$ ls -l total 36 -rw-r--r-- 1 march march 35001 May 6 18:41 Makefile
-
Finaly to make current set of programs print:
$ make -
After build step move to
<build_folder>/bin(<build_folder>/modbus/bin)to ensure everything is correct:$ cd bin $ pwd ~/bin/ModbusTools/bin $ ls -l total 2672 -rwxr-xr-x 1 march march 643128 May 6 18:45 client lrwxrwxrwx 1 march march 16 May 6 18:44 libcore.so -> libcore.so.0.1.4 lrwxrwxrwx 1 march march 16 May 6 18:44 libcore.so.0 -> libcore.so.0.1.4 lrwxrwxrwx 1 march march 16 May 6 18:44 libcore.so.0.1 -> libcore.so.0.1.4 -rwxr-xr-x 1 march march 993376 May 6 18:44 libcore.so.0.1.4 -rwxr-xr-x 1 march march 907872 May 6 18:47 server $ cd ~/bin/ModbusTools/modbus/bin $ ls -l total 264 lrwxrwxrwx 1 march march 18 Sep 27 16:24 libmodbus.so -> libmodbus.so.1.0.0 lrwxrwxrwx 1 march march 18 Sep 27 16:24 libmodbus.so.1 -> libmodbus.so.1.0.0 lrwxrwxrwx 1 march march 18 Sep 27 16:24 libmodbus.so.1.0 -> libmodbus.so.1.0.0 -rwxr-xr-x 1 march march 269888 Sep 27 16:24 libmodbus.so.1.0.0
The ModbusTools project requires Qt version 5.8 or later.
- Download qt-online-installer, follow the link and choose Windows version for installer:
https://www.qt.io/download-qt-installer
- Run qt-online-installer and install all necessary components: Qt 5 (Qt5.15.2) framework.
Qt 5.8 or higher is needed so in Select Components window check Archive checkbox and push Filter button.
Then is better to check latest version of Qt5.15 framework (e.g. 5.15.2)
-
Download and install git for Windows or use WSL and install git for WSL.
-
Make dir for binaries, e.g. in
<user-home-dir>\bin\ModbusToolsusing Windows command console:>cd `<user-home-dir>` >mkdir bin\ModbusTools >cd bin\ModbusTools
-
Clone repository:
$ git clone --recursive https://github.com/serhmarch/ModbusTools.git
This example shows how to build ModbusTools for MSVC compiler using qmake.
-
Open Windows command console and initialize all MSVC compiler vars (e.g. include, lib) using
vcvarsall.batscript. This script will be configured for x64 arch (use...\vcvarsall.bat -helpto display all options): `console"c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 `
-
Run qmake to produce
Makefile. This command will makeReleaseversion, forDebugreplase with"CONFIG+=debug": `consoleC:\Qt\5.15.2\msvc2019_64\bin\qmake.exe path\to\ModbusTools.pro -spec win32-msvc "CONFIG+=release" `
-
Produce all make files:
>C:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile qmake_all -
Build project from Makefile's:
>C:\Qt\Tools\QtCreator\bin\jom\jom.exe
- Run cmake to generate project (make) files.
CMAKE_PREFIX_PATHmust be set to installed Qt framewrok files: `consolecmake -DCMAKE_PREFIX_PATH:PATH=C:/Qt/5.15.2/msvc2019_64 -S path\to\ModbusTools -B . `
- Make binaries (+ debug|release config):
$ cmake --build . $ cmake --build . --config Debug $ cmake --build . --config Release
- Resulting bin files is located in
DebugorReleasedirectory.
cmake --preset "Win64-MSVC"
cmake --build --preset "Win64-MSVC-Debug"
cmake --build --preset "Win64-MSVC-Release"To install compiled binaries and other necessary files run next command:
> cmake --install <build_dir> --prefix <install_dest_dir>Next command installs files from build dir into ModbusTools dir of user's home directory:
> cmake --install . --prefix "%USERPROFILE%\ModbusTools"The application will be compiled and run inside a Docker container. The GUIs will be exposed via a web server on port 6080.
-
Build the Docker image
docker build --platform=linux/amd64 -t modbustool . -
Run the docker image
docker run -p 6080:6080 modbustools -
Access the application at
http://localhost:6080/vnc.html
General view of ModbusTools application dir:
- modbus.dll
- core.dll
- server.exe
- client.exe
- script : [dir]
- server : [dir]
- mbconfig.py
- mbserver.py
- modbus.py
- server : [dir]
- help : [dir]
- ModbusClient.qch
- ModbusClient.qhc
- ModbusServer.qch
- ModbusServer.qhc
Arch Linux can install modbustools-git via the AUR.
yay -Syu modbustools