Эх сурвалжийг харах

Instructions to build libmodbus in a VS project

Tested with Visual Studio 2022.
Stéphane Raimbault 2 жил өмнө
parent
commit
9a7ea12928
3 өөрчлөгдсөн 43 нэмэгдсэн , 22 устгасан
  1. 2 2
      README.md
  2. 41 0
      src/win32/README.md
  3. 0 20
      src/win32/README.win32

+ 2 - 2
README.md

@@ -38,8 +38,8 @@ date (run `ldconfig` as root if required).
 The library provides a *libmodbus.pc* file to use with `pkg-config` to ease your
 program compilation and linking.
 
-If you want to compile with Microsoft Visual Studio, you need to install
-<https://github.com/chemeris/msinttypes> to fill the absence of stdint.h.
+If you want to compile with Microsoft Visual Studio, you should follow the
+instructions in `./src/win32/README.md`.
 
 To compile under Windows, install [MinGW](http://www.mingw.org/) and MSYS then
 select the common packages (gcc, automake, libtool, etc). The directory

+ 41 - 0
src/win32/README.md

@@ -0,0 +1,41 @@
+# 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`.
+
+1. copy the file `config.h` from `src/win32` to `src`.
+2. create a new 'Console App' project under Visual Studio.
+3. create a new directory called `libmodbus` inside your VS project (same level
+   as the `.vcxproj` file).
+4. copy all `*.c` and `*.h` from libmodbus `src` in the new `libmodbus` folder
+   of your VS project.
+5. copy `modbus.rc` in your VS project (same level as the `.vcxproj` file).
+6. drag and drop `libmodbus/*.c` files (4) in *Solution Explorer -> Source Files*.
+7. drag and drop `libmodbus/*.h` files (8) in *Solution Explorer -> Header Files*.
+8. drag and drop `modbus.rc` file in *Solution Explorer -> Resource Files*.
+9. check path is `#include "modbus-version.h"` in `modbus.rc`.
+10. in the **Property Pages** of the project *Configuration Properties -> C/C++
+    -> General -> Additional Include Directories*, add `libmodbus` folder.
+11. in the **Property Pages** of the project *Configuration Properties ->
+    Resources -> Additional Include Directories*, add `libmodbus` folder.
+12. in the **Property Pages** of the project *Configuration Properties -> Linker
+    -> Input*, define `ws2_32.lib`.
+13. if required, add `_CRT_SECURE_NO_WARNINGS` to *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.h`
+- `modbus-version.h` are generated using configure.js.
+
+To write...

+ 0 - 20
src/win32/README.win32

@@ -1,20 +0,0 @@
-Intro
------
-
-This directory contains the project file for Visual Studio 2008 to build
-modbus.dll and the import library modbus.lib.
-
-The project file looks for D:/include/msvc_std to find stdint.h.
-See ../../README.md file.
-
-config.h and ../modbus-version.h are generated using configure.js.
-
-Run
-    cscript configure.js
-or
-    wscript configure.js
-or
-   double click configure.js to generate these files.
-
-To get project file for Visual Studio 2005 open copy of file modbus.vcproj in
-editor and change attribute `Version` of `VisualStudioProject` tag to "8,00".