Detours
Detours copied to clipboard
Compiling Detours
I don't want to use VCPKG as I find it difficult to understand. NuGet Manager was simple.
So I used GitHub Desktop to clone the repository to my pc. Then I opened the solution file in Visual Studio 2022.
But it says:
D:\My Libraries\Detours\vc\Detours.vcxproj : warning : The build tools for Visual Studio 2019 (v142) cannot be found. Install Visual Studio 2019 (v142) to build using the Visual Studio 2019 (v142) build tools.
I don't want to install the 2019 build tools. Can I configure it for 2022 build tools?
So I closed the SLN file and opened the VCXPROJ file instead and tried to cmpile debug x86:
>Done building project "Detours.vcxproj" -- FAILED.
1>
1>Build FAILED.
1>
1>error CS1668 : Warning as error : Invalid search path 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.29.30133\atlmfc\lib\x86' specified in 'LIB environment variable' -- 'The system cannot find the path specified. '
1>NMAKE : fatal error U1077: 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.EXE' : return code '0x1'
1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\nmake.exe"' : return code '0x2'
1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\nmake.exe"' : return code '0x2'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(46,5): error MSB3073: The command "SET DETOURS_TARGET_PROCESSOR=x86
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(46,5): error MSB3073: cd ..
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(46,5): error MSB3073: nmake" exited with code 2.
Either way, I can't compile the x86 or x64 library files. Please advise.
Did you include ATL / MFC when installing Visual Studio?
@lwahonen I definitely have MFC installed as I use it. What I think might be happening is that the Detours project is configured for v142 toolset and I have v143. So I am going to try and update to my toolset I am using.
Also, I don’t understand why there is not a build option to just build the library files and not the samples. All I want is the library / header for use in my project with another third party header that implements dark mode task dialogs.
@lwahonen
I edited the vcxproj file and replaced:
<PlatformToolset>v142</PlatformToolset>
with
<PlatformToolset>v143</PlatformToolset>
Now it compiles with no errors.
@lwahonen
Can support for v143 be officially added?
nmake is the way to go IMO, it is the original build system used by detours and will automatically use your current platform toolset. I don't quite understand why a competing build system (vcxproj) was added.
Either way, VS should've offered you to upgrade the platform toolset when opening the solution but I guess it didn't. Manually changing it is fine.
@sylveon
I haven’t used nmake before. At least it works now. But I can’t stand this VCPKG concept. I like simple step by step instructions. I did try to install / configure so that Detours is auto maintained but things went wrong. Thus I compiled directly with the solution myself.
The FAQ has step by step instructions for building via nmake: https://github.com/microsoft/detours/wiki/faq#where-can-i-find-detourslib-and-detoursh
Sure, I have tried using the VC Command Prompt:
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.12.4
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
C:\Users\ajtru\source\repos>d:
D:\>cd D:\My Libraries\Detours\src
D:\My Libraries\Detours\src>nmake -f makefile
Microsoft (R) Program Maintenance Utility Version 14.42.34436.0
Copyright (C) Microsoft Corporation. All rights reserved.
link /lib /out:..\lib.X86\detours.lib /nologo obj.X86\detours.obj obj.X86\modules.obj obj.X86\disasm.obj obj.X86\image.obj obj.X86\creatwth.obj obj.X86\disolx86.obj obj.X86\disolx64.obj obj.X86\disolia64.obj obj.X86\disolarm.obj obj.X86\disolarm64.obj
D:\My Libraries\Detours\src>
But that is not a full compile like I get in VS 2022.
How can I build the project?
Thank you in advance. Johnson
Build it from a developer command prompt
Thank you for your help, @sylveon
But, just I'm using Visual Studio 2015, and I can't find it in the app.
How to use developer command prompt in Visual Studio 2015?
So, just I used on Win -> Developer Command Prompt
But same issue...
:(