c++ - 如何编译Detours Express 3.0?

标签 c++ windows detours

我最近一直在尝试编译微软的Detours库,免费版叫做“Express 3.0”。在其 README 指南中,它告诉您使用“nmake”。我在 detours 目录中打开了一个命令窗口并尝试了“nmake”。 它说:“nmake 不被识别为内部命令......”。

我打开了 VS2015 x86 native 工具命令提示符,使用 cd 将当前目录更改为该文件夹,然后尝试“nmake all”:

C:\Windows\system32>cd C:\Program Files (x86)\Microsoft Research\Detours Express 3.0

C:\Program Files (x86)\Microsoft Research\Detours Express 3.0>nmake all

Microsoft (R) Program Maintenance Utility Version 14.00.23026.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cd "C:\Program Files (x86)\Microsoft Research\Detours Express 3.0\src"
 Created ..\include
 Created ..\lib.X86
 Created ..\bin.X86
 Created obj.X86
        cl /W4 /WX /Zi /MTd /Gy /Gm- /Zl /Od /DDETOURS_BITS=32 /DWIN32_LEAN_AND_MEAN /D_WIN32_WINNT=0x403 /Gs /DDETOURS_X86=1 /DDETOURS_32BIT=1 /D_X86_ /DDETOURS_OPTION_BITS=64 /Fd..\lib.X86\detours.pdb /Foobj.X86\detours.obj /c .\detours.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

detours.cpp
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(1544): error C2220: warning treated as error - no 'object' file generated
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(1544): warning C4091: 'typedef ': ignored on left of '' when no variable is declared
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(3190): warning C4091: 'typedef ': ignored on left of '' when no variable is declared
.\detours.cpp(156): warning C4456: declaration of 'pbNew' hides previous local declaration
.\detours.cpp(156): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
.\detours.cpp(147): note: see declaration of 'pbNew'
.\detours.cpp(163): warning C4456: declaration of 'pbNew' hides previous local declaration
.\detours.cpp(163): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
.\detours.cpp(147): note: see declaration of 'pbNew'
.\detours.cpp(1263): warning C4456: declaration of 'o' hides previous local declaration
.\detours.cpp(1263): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
.\detours.cpp(1112): note: see declaration of 'o'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

C:\Program Files (x86)\Microsoft Research\Detours Express 3.0>set DETOURS_TARGET_PROCESSOR=x86

C:\Program Files (x86)\Microsoft Research\Detours Express 3.0>nmake all

Microsoft (R) Program Maintenance Utility Version 14.00.23026.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cd "C:\Program Files (x86)\Microsoft Research\Detours Express 3.0\src"
        cl /W4 /WX /Zi /MTd /Gy /Gm- /Zl /Od /DDETOURS_BITS=32 /DWIN32_LEAN_AND_MEAN /D_WIN32_WINNT=0x403 /Gs /DDETOURS_X86=1 /DDETOURS_32BIT=1 /D_X86_ /DDETOURS_OPTION_BITS=64 /Fd..\lib.X86\detours.pdb /Foobj.X86\detours.obj /c .\detours.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

detours.cpp
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(1544): error C2220: warning treated as error - no 'object' file generated
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(1544): warning C4091: 'typedef ': ignored on left of '' when no variable is declared
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(3190): warning C4091: 'typedef ': ignored on left of '' when no variable is declared
.\detours.cpp(156): warning C4456: declaration of 'pbNew' hides previous local declaration
.\detours.cpp(156): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
.\detours.cpp(147): note: see declaration of 'pbNew'
.\detours.cpp(163): warning C4456: declaration of 'pbNew' hides previous local declaration
.\detours.cpp(163): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
.\detours.cpp(147): note: see declaration of 'pbNew'
.\detours.cpp(1263): warning C4456: declaration of 'o' hides previous local declaration
.\detours.cpp(1263): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
.\detours.cpp(1112): note: see declaration of 'o'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

C:\Program Files (x86)\Microsoft Research\Detours Express 3.0>

我该怎么办?我使用 Windows 10 和 Visual Studio 2015。

最佳答案

在“Detours Express 3.0”目录中打开“\src\Makefile”。

修改第19行如下:

CFLAGS=/W3 /Zi /MTd /Gy /Gm- /Zl /Od /DDETOURS_BITS=$(DETOURS_BITS)

这意味着将选项“/W4”更改为“/W3”并删除选项“/WX”。

然后重做“nmake”。

您的问题将得到解决。

关于c++ - 如何编译Detours Express 3.0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33572943/

相关文章:

windows - 如何从WP7上的GPS获取经度和纬度?

javascript - 从 Windows 应用程序中的 MainPage.xaml.cs 代码隐藏文件调用 javascript 函数

c++ - 使用detours Hook 在记事本中书写文字

c++ - 使用抽象类的 STL 排序

C++ 抽象类模板 + 特定类型的子类 = 链接器有问题

windows - 网络问题,求建议

c++ - 为什么C++中的API hook ExtTextOut和DrawText只会输出垃圾?

c++ - 钩子(Hook)查找窗口

c++ - 对(函数)c++ 的 undefined reference

c++ - 使用 Batch,如何确定您是否连接到 WiFi 网络?