From ac7f6806eb41079ff20d697bd787b67868f54f21 Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 18 Sep 2023 07:10:41 +1000 Subject: [PATCH] I suffered greatly trying to get the libraries to build correctly Because one has to separately specify build characteristics in many different places it is quite difficult to make sure the right things are linking the right things. I added the two files msvc/winConfigDebug.bat msvc/winConfigRelease.bat To build only the libaries that should be linked, so we will get an error message if a release build links to a debug build. --- libsodium | 2 +- msvc/wallet.vcxproj | 12 ++--- msvc/winConfig.bat | 3 +- msvc/winConfigDebug.bat | 91 ++++++++++++++++++++++++++++++++++ msvc/winConfigRelease.bat | 100 ++++++++++++++++++++++++++++++++++++++ src/stdafx.h | 1 - wallet.sln | 2 +- 7 files changed, 201 insertions(+), 10 deletions(-) create mode 100644 msvc/winConfigDebug.bat create mode 100644 msvc/winConfigRelease.bat diff --git a/libsodium b/libsodium index 5bfb49a..914033d 160000 --- a/libsodium +++ b/libsodium @@ -1 +1 @@ -Subproject commit 5bfb49a8e40afe7aa349dd469bd11d9d76c71930 +Subproject commit 914033d2c70831b86e94a25f27e61a94bc7d45c8 diff --git a/msvc/wallet.vcxproj b/msvc/wallet.vcxproj index 49c8256..e9799ea 100644 --- a/msvc/wallet.vcxproj +++ b/msvc/wallet.vcxproj @@ -44,7 +44,7 @@ true $(SolutionDir)wxWidgets\include\msvc;$(SolutionDir)wxWidgets\include;$(SolutionDir)libsodium\src\libsodium\include;$(SolutionDir)mpir;$(IncludePath) - $(SolutionDir)wxWidgets\lib\vc_x64_lib\;$(SolutionDir)libsodium\Build\Debug\X64;$(SolutionDir)mpir\lib\x64\Debug;$(LibraryPath) + $(SolutionDir)wxWidgets\lib\vc_x64_lib\;$(SolutionDir)libsodium\bin\x64\Debug\v143\static;$(SolutionDir)mpir\lib\x64\Debug;$(LibraryPath) $(SolutionDir)build\$(Configuration)\ $(SolutionDir)build\$(Configuration)\ @@ -52,7 +52,7 @@ false $(SolutionDir)wxWidgets\include\msvc;$(SolutionDir)wxWidgets\include;$(SolutionDir)libsodium\src\libsodium\include;$(SolutionDir)mpir;$(IncludePath) - $(SolutionDir)wxWidgets\lib\vc_x64_lib\;$(SolutionDir)libsodium\Build\Release\X64;$(SolutionDir)mpir\lib\x64\Release;$(LibraryPath) + $(SolutionDir)wxWidgets\lib\vc_x64_lib\;$(SolutionDir)libsodium\bin\x64\Release\v143\static;$(SolutionDir)mpir\lib\x64\Release;$(LibraryPath) $(SolutionDir)build\$(Configuration)\ $(SolutionDir)build\$(Configuration)\ @@ -75,9 +75,8 @@ Windows true - - - mpir.lib;mpirxx.lib;%(AdditionalDependencies) + /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib + mpir.lib;mpirxx.lib;libsodium.lib;%(AdditionalDependencies) wallet.manifest %(AdditionalManifestFiles) @@ -115,7 +114,8 @@ true true true - mpir.lib;mpirxx.lib;%(AdditionalDependencies) + mpir.lib;mpirxx.lib;libsodium.lib;%(AdditionalDependencies) + /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib %(AdditionalOptions) diff --git a/msvc/winConfig.bat b/msvc/winConfig.bat index e07468d..d5de85e 100644 --- a/msvc/winConfig.bat +++ b/msvc/winConfig.bat @@ -114,7 +114,8 @@ echo off IF %ERRORLEVEL% NEQ 0 ( echo failed unit test on debug build ) ELSE ( - echo passed unit test on debug build) + echo passed unit test on debug build +) echo on .\build\Release\wallet.exe --complete --test echo off diff --git a/msvc/winConfigDebug.bat b/msvc/winConfigDebug.bat new file mode 100644 index 0000000..85bb725 --- /dev/null +++ b/msvc/winConfigDebug.bat @@ -0,0 +1,91 @@ +echo as it is a bitch to make sure you are linking to the correct libraries, this batch Files +echo exists to make sure no other libraries are around +echo off +call C:\"Program Files (x86)"\"Microsoft Visual Studio"\2022\BuildTools\VC\Auxiliary\Build\vcvarsamd64_x86.bat +call C:\"Program Files"\"Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build\vcvars64.bat" +del /Q build +del /Q libsodium\obj +del /Q libsodium\bin +del /Q libsodium\src\libsodium\include\sodium\version.h +cd mpir +del config.h +del gmp-mparam.h +del gmp.h +del /Q lib +del longlong.h +del mpir.h +del msvc\output_params.bat +del msvc\tmp.h +del /Q msvc\vs22\lib_mpir_cxx\x64 +del /Q msvc\vs22\lib_mpir_gc\x64 +del msvc\vs22\test-config.props +cd ..\wxWidgets +del /Q build\msw\vc_x64_mswu +del /Q build\msw\vc_x64_mswud +del /Q lib\vc_x64_lib +cd .. +echo check to see that everything is cleaned +echo off +git submodule foreach --recursive "git clean -xnf" +git clean -xnf +PAUSE +echo on + +cd libsodium/builds/msvc/vs2022 +msbuild libsodium.sln -p:Configuration=StaticDebug;Platform=x64 -m +echo off +IF %ERRORLEVEL% NEQ 0 ( + cd .. + PAUSE + GOTO:EOF +) +echo on +echo on +cd ../../../.. +cd mpir\msvc\vs22 +call msbuild.bat gc lib x64 Debug +echo off +IF %ERRORLEVEL% NEQ 0 ( + cd .. + PAUSE + GOTO:EOF +) +echo on +call msbuild.bat gc lib x64 Debug test +echo off +IF %ERRORLEVEL% NEQ 0 ( + cd .. + PAUSE + GOTO:EOF +) +echo on +call msbuild.bat gc lib x64 Debug tune +echo off +IF %ERRORLEVEL% NEQ 0 ( + cd .. + PAUSE + GOTO:EOF +) +echo on + +echo on +cd ..\..\.. +cd wxWidgets\build\msw +echo on +msbuild wx_vc17.sln -m -p:Configuration=Debug;Platform=x64;PlatformToolset=v143;WindowsTargetPlatformVersion=10.0 +echo off +IF %ERRORLEVEL% NEQ 0 ( + PAUSE + GOTO:EOF +) + + +cd ..\..\.. +msbuild wallet.sln -p:Configuration=Debug;Platform=x64 -m +.\build\Debug\wallet.exe --complete --test +echo off +IF %ERRORLEVEL% NEQ 0 ( + echo failed unit test on debug build +) ELSE ( + echo passed unit test on debug build +) diff --git a/msvc/winConfigRelease.bat b/msvc/winConfigRelease.bat new file mode 100644 index 0000000..eb2396a --- /dev/null +++ b/msvc/winConfigRelease.bat @@ -0,0 +1,100 @@ +echo as it is a bitch to make sure you are linking to the correct libraries, this batch Files +echo exists to make sure no other libraries are around +echo off +call C:\"Program Files (x86)"\"Microsoft Visual Studio"\2022\BuildTools\VC\Auxiliary\Build\vcvarsamd64_x86.bat +call C:\"Program Files"\"Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build\vcvars64.bat" +del /Q build +del /Q libsodium\obj +del /Q libsodium\bin +del /Q libsodium\src\libsodium\include\sodium\version.h +cd mpir +del config.h +del gmp-mparam.h +del gmp.h +del /Q lib +del longlong.h +del mpir.h +del msvc\output_params.bat +del msvc\tmp.h +del /Q msvc\vs22\lib_mpir_cxx\x64 +del /Q msvc\vs22\lib_mpir_gc\x64 +del msvc\vs22\test-config.props +cd ..\wxWidgets +del /Q build\msw\vc_x64_mswu +del /Q build\msw\vc_x64_mswud +del /Q lib\vc_x64_lib +cd .. +echo check to see that everything is cleaned +echo off +git submodule foreach --recursive "git clean -xnf" +git clean -xnf +PAUSE +echo on +cd libsodium/builds/msvc/vs2022 +msbuild libsodium.sln -p:Configuration=StaticRelease;Platform=x64 -m +echo off +IF %ERRORLEVEL% NEQ 0 ( + cd .. + PAUSE + GOTO:EOF +) +echo on +cd ../../../.. +cd mpir\msvc\vs22 +echo on +call msbuild.bat gc lib x64 Release +echo off +IF %ERRORLEVEL% NEQ 0 ( + cd .. + PAUSE + GOTO:EOF +) +echo on +call msbuild.bat gc lib x64 Release test +echo off +IF %ERRORLEVEL% NEQ 0 ( + cd .. + PAUSE + GOTO:EOF +) +echo on +call msbuild.bat gc lib x64 Release tune +echo off +IF %ERRORLEVEL% NEQ 0 ( + cd .. + PAUSE + GOTO:EOF +) +echo on +cd ..\..\.. +cd wxWidgets\build\msw +msbuild wx_vc17.sln -m -p:Configuration=Release;Platform=x64;PlatformToolset=v143;WindowsTargetPlatformVersion=10.0 +echo off +IF %ERRORLEVEL% NEQ 0 ( + PAUSE + GOTO:EOF +) +echo on +msbuild wx_vc17.sln -m -p:Configuration=Debug;Platform=x64;PlatformToolset=v143;WindowsTargetPlatformVersion=10.0 +echo off +IF %ERRORLEVEL% NEQ 0 ( + PAUSE + GOTO:EOF +) + +echo on +cd ..\..\.. +msbuild wallet.sln -p:Configuration=Release;Platform=x64 -m +echo off +IF %ERRORLEVEL% NEQ 0 ( + PAUSE + GOTO:EOF +) +echo on +.\build\Release\wallet.exe --complete --test +echo off +IF %ERRORLEVEL% NEQ 0 ( + echo failed unit test on release build +) ELSE ( + echo passed unit test on release build +) diff --git a/src/stdafx.h b/src/stdafx.h index 91ec2dc..a48208b 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -82,7 +82,6 @@ std::span& operator^=(std::span&, byte *); #define SODIUM_STATIC 1 #include #include -#pragma comment(lib, "libsodium.lib") inline wxString _wx(const char* sz) { return wxString::FromUTF8Unchecked(sz); } #include "introspection_of_standard_C_types.h" // This header file turns off deprecation of array type compares, because diff --git a/wallet.sln b/wallet.sln index 45b6602..bbd3a98 100644 --- a/wallet.sln +++ b/wallet.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.32014.148 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wallet", "msvc/wallet.vcxproj", "{B1EC18D5-FA70-4A59-8CAE-EDC65A358314}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wallet", "msvc\wallet.vcxproj", "{B1EC18D5-FA70-4A59-8CAE-EDC65A358314}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2F7D488C-DC53-4ECE-87E2-4FEA32C153EF}" EndProject