To successfully complete this tutorial, you must do the following :
- Install [Visual Studio Code] (https://code.visualstudio.com/)
- Install the C/C++ extension for VS Code. You can install the C/C++ extension by searching for 'c++' in the Extensions view (Ctrl+Shift+X).
- Install Build Tools pour Visual Studio 2022
Installation following the instructions on the page Configure VS Code for Microsoft C++
- Download the latest version of CMake
- Install the CMake Tools extension for VS Code. . You can install the CMake Tools extension by searching for 'cmake' in the Extensions view (Ctrl+Shift+X).
This is a step-by-step procedure to get pkg-config working on Windows.
There were multiple versions of the packages available, and in each case I just downloaded the latest version.
- go to http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
- download the file pkg-config_0.26-1_win32.zip
- extract the file to C:\Info
- download the file gettext-runtime_0.18.1.1-2_win32.zip
- extract the file to C:\Info
- go to http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28
- download the file glib_2.28.8-1_win32.zip
- extract the file to C:\Info
- Adds the path C:\Info\bin to the PATH environment variable
- Download the latest version of Git for Windows
- Install Git for Windows
Open a git bash terminal :
git clone https://github.com/epsilonrt/mbpoll.git
cd mbpoll
git clone https://github.com/stephane/libmodbus.git
-
Open Visual Studio Code and open the folder
mbpoll
. -
Choose Visual Studio Community 2022 Realease - x86 as the kit in the Cmake status bar.
-
Choose the Release configuration in the Cmake status bar.
-
Click on the Configure button in the status bar to configure the project.
-
Click on the Build button in the status bar to build the project.
[main] Building folder: mbpoll [build] Starting build [proc] Executing command: C:\Info\CMake\bin\cmake.EXE --build c:/Users/pasca/OneDrive/Documents/src/mbpoll/build --config Release --target ALL_BUILD -j 18 -- [build] MSBuild version 17.5.0+6f08c67f3 for .NET Framework [build] [build] Microsoft (R) Windows Script Host Version 5.812 [build] Copyright (C) Microsoft Corporation. Tous droits réservés. [build] [build] ..\modbus-version.h created. [build] modbus.dll.manifest created. [build] config.h created. [build] [build] Libmodbus configuration completed [build] [build] modbus-data.c [build] C:\Users\pasca\OneDrive\Documents\src\mbpoll\libmodbus\src\modbus-data.c(77,6): warning C4273: 'modbus_set_bits_from_byte' : liaison DLL incohérente [C:\Users\pasca\OneDrive\Documents\src\mbpoll\build\mbpoll.vcxproj] ....... [build] LINK : warning LNK4217: le symbole '_modbus_set_bits_from_bytes' défini dans 'modbus-data.obj' est importé par 'modbus.obj' dans la fonction '_modbus_reply' [C:\Users\pasca\OneDrive\Documents\src\mbpoll\build\mbpoll.vcxproj] [build] mbpoll.vcxproj -> C:\Users\pasca\OneDrive\Documents\src\mbpoll\build\Release\mbpoll.exe [driver] Build completed: 00:00:04.712 [build] Build finished with exit code 0
The warnings LNK4217 and C4273 are normal.
- Download the latest version of Innosetup
- Go to the folder
mbpoll\package\win
and open the filembpoll.iss
with Innosetup - Download the Microsoft Visual C++ Redistributable latest from https://aka.ms/vs/17/release/vc_redist.x86.exe and copy it to
mbpoll\package\win\tmp\vcredist_x86.exe
- Compile the installer with Innosetup
- Get the installer in the folder
mbpoll\package\win\installer