README.md
Instructions to compile on Windows
Create a new Visual Studio project with the library included
Download the latest version of libmodbus source code from Github
https://github.com/stephane/libmodbus -> Code -> Download ZIP.
Once the archive is decompressed, launch a Windows terminal (cmd) in
src/win32 directory and run cscript configure.js.
- copy the file
config.hfromsrc/win32tosrc. - create a new 'Console App' project under Visual Studio.
- create a new directory called
libmodbusinside your VS project (same level as the.vcxprojfile). - copy all
*.cand*.hfrom libmodbussrcin the newlibmodbusfolder of your VS project. - copy
modbus.rcin your VS project (same level as the.vcxprojfile). - drag and drop
libmodbus/*.cfiles (4) in Solution Explorer -> Source Files. - drag and drop
libmodbus/*.hfiles (8) in Solution Explorer -> Header Files. - drag and drop
modbus.rcfile in Solution Explorer -> Resource Files. - check path is
#include "modbus-version.h"inmodbus.rc. - in the Property Pages of the project Configuration Properties -> C/C++
-> General -> Additional Include Directories, add
libmodbusfolder. - in the Property Pages of the project Configuration Properties ->
Resources -> Additional Include Directories, add
libmodbusfolder. - in the Property Pages of the project Configuration Properties -> Linker
-> Input, define
ws2_32.lib. - if required, add
_CRT_SECURE_NO_WARNINGSto C/C++ -> Preprocessor -> Preprocessor Definitions.
Create a libmodbus DLL
This directory contains the project file for Visual Studio to build modbus.dll
and import library modbus.lib.
In the Windows terminal, run cscript configure.js to generate:
config.hmodbus-version.hare generated using configure.js.
To write...