From 0294a4bac4dd1c94dfb0636f08be88fe226974a8 Mon Sep 17 00:00:00 2001 From: Raymond Berg Hansen Date: Mon, 24 Jul 2023 10:27:48 +0200 Subject: [PATCH 1/6] Updated to Visual Studio 2022. Renamed win32 folder to only win (is also x64 now). Updated and renamed project file. Some misc clean up in files. --- src/{win32 => win}/Make-tests | 0 src/win/README.md | 10 + src/{win32 => win}/config.h.win32 | 0 src/{win32 => win}/configure.js | 0 src/win/libmodbus.sln | 31 ++ src/win/libmodbus.vcxproj | 254 +++++++++++++++++ src/win/libmodbus.vcxproj.filters | 62 ++++ src/{win32 => win}/modbus.rc | 0 src/win32/README.md | 41 --- src/win32/modbus-9.sln | 20 -- src/win32/modbus.dll.manifest.in | 14 - src/win32/modbus.vcproj | 457 ------------------------------ 12 files changed, 357 insertions(+), 532 deletions(-) rename src/{win32 => win}/Make-tests (100%) create mode 100644 src/win/README.md rename src/{win32 => win}/config.h.win32 (100%) rename src/{win32 => win}/configure.js (100%) create mode 100644 src/win/libmodbus.sln create mode 100644 src/win/libmodbus.vcxproj create mode 100644 src/win/libmodbus.vcxproj.filters rename src/{win32 => win}/modbus.rc (100%) delete mode 100644 src/win32/README.md delete mode 100644 src/win32/modbus-9.sln delete mode 100644 src/win32/modbus.dll.manifest.in delete mode 100644 src/win32/modbus.vcproj diff --git a/src/win32/Make-tests b/src/win/Make-tests similarity index 100% rename from src/win32/Make-tests rename to src/win/Make-tests diff --git a/src/win/README.md b/src/win/README.md new file mode 100644 index 000000000..fd44c00e2 --- /dev/null +++ b/src/win/README.md @@ -0,0 +1,10 @@ +# Instructions to compile on Windows + +## Create a new Visual Studio project with the library included + +This is solution is build and tested in Visual Studio 2022 CE. + +Clone the latest version of libmodbus source code from Github. + +1. Open libmodbus solution in VS (`libmodbus.sln`). +2. Use Powershell terminal in VS and run `cscript configure.js` (You should already be in the `src/win` directory). diff --git a/src/win32/config.h.win32 b/src/win/config.h.win32 similarity index 100% rename from src/win32/config.h.win32 rename to src/win/config.h.win32 diff --git a/src/win32/configure.js b/src/win/configure.js similarity index 100% rename from src/win32/configure.js rename to src/win/configure.js diff --git a/src/win/libmodbus.sln b/src/win/libmodbus.sln new file mode 100644 index 000000000..5c7bd0cb6 --- /dev/null +++ b/src/win/libmodbus.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmodbus", "libmodbus.vcxproj", "{498E0845-C7F4-438B-8EDE-EF7FC9A74430}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Debug|x64.ActiveCfg = Debug|x64 + {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Debug|x64.Build.0 = Debug|x64 + {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Debug|x86.ActiveCfg = Debug|Win32 + {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Debug|x86.Build.0 = Debug|Win32 + {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Release|x64.ActiveCfg = Release|x64 + {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Release|x64.Build.0 = Release|x64 + {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Release|x86.ActiveCfg = Release|Win32 + {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A44358E6-8E35-4B20-A35A-8CD98DDF11C7} + EndGlobalSection +EndGlobal diff --git a/src/win/libmodbus.vcxproj b/src/win/libmodbus.vcxproj new file mode 100644 index 000000000..e4c745683 --- /dev/null +++ b/src/win/libmodbus.vcxproj @@ -0,0 +1,254 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 17.0 + {498E0845-C7F4-438B-8EDE-EF7FC9A74430} + modbus + Win32Proj + libmodbus + 10.0 + + + + DynamicLibrary + v143 + MultiByte + true + + + DynamicLibrary + v143 + MultiByte + true + + + DynamicLibrary + v143 + MultiByte + + + DynamicLibrary + v143 + MultiByte + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>17.0.33815.168 + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + + + + + + + + + + + X64 + + + Disabled + false + $(SolutionDir);%(AdditionalIncludeDirectories) + false + EnableFastChecks + MultiThreaded + + Level3 + ProgramDatabase + CompileAsC + 4244;4267;%(DisableSpecificWarnings) + + + true + Console + 1048576 + 524288 + MachineX64 + "WS2_32.lib";"msvcrt.lib";%(AdditionalDependencies) + + + + + + + + + + + + + + + + Disabled + false + $(SolutionDir);%(AdditionalIncludeDirectories) + false + EnableFastChecks + MultiThreaded + + + Level3 + ProgramDatabase + CompileAsC + 4244;4267;%(DisableSpecificWarnings) + + + true + Console + 1048576 + 524288 + "WS2_32.lib";"msvcrt.lib";%(AdditionalDependencies) + + + + + + + + + + + + X64 + + + MaxSpeed + true + false + $(SolutionDir);%(AdditionalIncludeDirectories) + MultiThreaded + true + + Level3 + ProgramDatabase + CompileAsC + 4244;4267;%(DisableSpecificWarnings) + + + true + Console + 1048576 + 524288 + true + true + + MachineX64 + "WS2_32.lib";"msvcrt.lib";%(AdditionalDependencies) + + + + + + + + + + + + + + + + MaxSpeed + true + false + $(SolutionDir);%(AdditionalIncludeDirectories) + MultiThreaded + true + + + Level3 + ProgramDatabase + CompileAsC + 4244;4267;%(DisableSpecificWarnings) + + + true + Console + 1048576 + 524288 + true + true + + + "WS2_32.lib";"msvcrt.lib";%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/win/libmodbus.vcxproj.filters b/src/win/libmodbus.vcxproj.filters new file mode 100644 index 000000000..ebfdc5c36 --- /dev/null +++ b/src/win/libmodbus.vcxproj.filters @@ -0,0 +1,62 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/src/win32/modbus.rc b/src/win/modbus.rc similarity index 100% rename from src/win32/modbus.rc rename to src/win/modbus.rc diff --git a/src/win32/README.md b/src/win32/README.md deleted file mode 100644 index 6b3957df0..000000000 --- a/src/win32/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# 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... diff --git a/src/win32/modbus-9.sln b/src/win32/modbus-9.sln deleted file mode 100644 index b84f0f5a7..000000000 --- a/src/win32/modbus-9.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modbus", "modbus.vcproj", "{498E0845-C7F4-438B-8EDE-EF7FC9A74430}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Debug|Win32.ActiveCfg = Debug|Win32 - {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Debug|Win32.Build.0 = Debug|Win32 - {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Release|Win32.ActiveCfg = Release|Win32 - {498E0845-C7F4-438B-8EDE-EF7FC9A74430}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/win32/modbus.dll.manifest.in b/src/win32/modbus.dll.manifest.in deleted file mode 100644 index 22ae3e00c..000000000 --- a/src/win32/modbus.dll.manifest.in +++ /dev/null @@ -1,14 +0,0 @@ - - - -Zsh shell - - - - - - - - - - diff --git a/src/win32/modbus.vcproj b/src/win32/modbus.vcproj deleted file mode 100644 index a7acb6b5c..000000000 --- a/src/win32/modbus.vcproj +++ /dev/null @@ -1,457 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 7e046cf445b8939fe0bb1294629b1cb9b844245a Mon Sep 17 00:00:00 2001 From: Raymond Berg Hansen Date: Mon, 24 Jul 2023 10:39:31 +0200 Subject: [PATCH 2/6] Ups, to much clean up. --- src/win/modbus.dll.manifest.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/win/modbus.dll.manifest.in diff --git a/src/win/modbus.dll.manifest.in b/src/win/modbus.dll.manifest.in new file mode 100644 index 000000000..22ae3e00c --- /dev/null +++ b/src/win/modbus.dll.manifest.in @@ -0,0 +1,14 @@ + + + +Zsh shell + + + + + + + + + + From 04d85764e77a6b4e73b7cba06ac9786b146545bf Mon Sep 17 00:00:00 2001 From: Raymond Berg Hansen Date: Mon, 24 Jul 2023 10:41:04 +0200 Subject: [PATCH 3/6] Added build instruction. --- src/win/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win/README.md b/src/win/README.md index fd44c00e2..ce24e945e 100644 --- a/src/win/README.md +++ b/src/win/README.md @@ -8,3 +8,4 @@ Clone the latest version of libmodbus source code from Github. 1. Open libmodbus solution in VS (`libmodbus.sln`). 2. Use Powershell terminal in VS and run `cscript configure.js` (You should already be in the `src/win` directory). +3. Build solution ("CTRL+SHIFT+B"). From 1827c533aae2021680b267cf2a32ea396ab6589c Mon Sep 17 00:00:00 2001 From: Raymond Berg Hansen Date: Mon, 24 Jul 2023 10:54:14 +0200 Subject: [PATCH 4/6] Removed instruction to make new project. --- src/win/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/win/README.md b/src/win/README.md index ce24e945e..897404991 100644 --- a/src/win/README.md +++ b/src/win/README.md @@ -1,11 +1,9 @@ # Instructions to compile on Windows -## Create a new Visual Studio project with the library included - -This is solution is build and tested in Visual Studio 2022 CE. +## This is solution is tested in Visual Studio 2022 CE. Clone the latest version of libmodbus source code from Github. -1. Open libmodbus solution in VS (`libmodbus.sln`). +1. Open libmodbus solution in VS (`src/win/libmodbus.sln`). 2. Use Powershell terminal in VS and run `cscript configure.js` (You should already be in the `src/win` directory). 3. Build solution ("CTRL+SHIFT+B"). From 4931844907be2d82830ee02e0cd064822e03882b Mon Sep 17 00:00:00 2001 From: Raymond Berg Hansen Date: Mon, 24 Jul 2023 13:45:41 +0200 Subject: [PATCH 5/6] =?UTF-8?q?Added=20=C2=B4cscript=20configure.js=C2=B4?= =?UTF-8?q?=20to=20pre-build.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/win/README.md | 3 +-- src/win/libmodbus.vcxproj | 16 +++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/win/README.md b/src/win/README.md index 897404991..1007eabcc 100644 --- a/src/win/README.md +++ b/src/win/README.md @@ -5,5 +5,4 @@ Clone the latest version of libmodbus source code from Github. 1. Open libmodbus solution in VS (`src/win/libmodbus.sln`). -2. Use Powershell terminal in VS and run `cscript configure.js` (You should already be in the `src/win` directory). -3. Build solution ("CTRL+SHIFT+B"). +2. Build solution ("CTRL+SHIFT+B"). diff --git a/src/win/libmodbus.vcxproj b/src/win/libmodbus.vcxproj index e4c745683..58eea3e73 100644 --- a/src/win/libmodbus.vcxproj +++ b/src/win/libmodbus.vcxproj @@ -90,7 +90,8 @@ - + cscript configure.js + Setup config.h and modbus-version.h @@ -123,8 +124,8 @@ - - + cscript configure.js + Setup config.h and modbus-version.h @@ -157,7 +158,8 @@ - + cscript configure.js + Setup config.h and modbus-version.h @@ -193,8 +195,8 @@ - - + cscript configure.js + Setup config.h and modbus-version.h @@ -241,9 +243,9 @@ + - From 84e7b09ac7e3baabdd30043997314d29aa51ca26 Mon Sep 17 00:00:00 2001 From: Raymond Berg Hansen Date: Sun, 17 Sep 2023 15:37:59 +0200 Subject: [PATCH 6/6] Fix for error messages. --- src/win/libmodbus.vcxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win/libmodbus.vcxproj b/src/win/libmodbus.vcxproj index 58eea3e73..49babbc19 100644 --- a/src/win/libmodbus.vcxproj +++ b/src/win/libmodbus.vcxproj @@ -79,7 +79,7 @@ true - $(SolutionDir)$(Platform)\$(Configuration)\ + $(ProjectDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ false @@ -106,7 +106,7 @@ $(SolutionDir);%(AdditionalIncludeDirectories) false EnableFastChecks - MultiThreaded + MultiThreadedDLL Level3 ProgramDatabase @@ -140,7 +140,7 @@ $(SolutionDir);%(AdditionalIncludeDirectories) false EnableFastChecks - MultiThreaded + MultiThreadedDLL Level3 @@ -172,8 +172,8 @@ MaxSpeed true false - $(SolutionDir);%(AdditionalIncludeDirectories) - MultiThreaded + $(ProjectDir);%(AdditionalIncludeDirectories) + MultiThreadedDLL true Level3 @@ -210,7 +210,7 @@ true false $(SolutionDir);%(AdditionalIncludeDirectories) - MultiThreaded + MultiThreadedDLL true