您的位置:首页 > 其它

解决Detours编译报错(在Win10+vs2015开发环境下)

2016-05-16 20:36 405 查看
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">1、首先去</span><a target=_blank href="http://research.microsoft.com/en-us/downloads/d36340fb-4d3c-4ddd-bf5b-1db25d03713d/default.aspx" style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">官网</a><span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">下载安装包DetoursExpress30.msi,点击安装</span>


express版本的特点:不能全局拦截,也不能源码级别拦截

3、编译

我这里使用Windows10和vs1015,

首先打开 所有应用-visual studio 2015-选择vs2015开发人员命令提示

进入DetoursExpress30的安装目录

cd D:\Software\DetourExpress30\src
输入nmake进行编译,出现如下错误

D:\Software\DetourExpress30>nmake

Microsoft (R) 程序维护实用工具 14.00.23026.0 版
版权所有 (C) Microsoft Corporation。  保留所有权利。

cd "D:\Software\DetourExpress30\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
用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.00.23026 版
版权所有(C) Microsoft Corporation。保留所有权利。

detours.cpp
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(1544): error C2220: 警告被视为错误 - 没有生成“object”文件
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(1544): warning C4091: “typedef ”: 没有声明变量时忽略“” 的左侧
C:\Program Files (x86)\Windows Kits\8.1\include\um\dbghelp.h(3190): warning C4091: “typedef ”: 没有声明变量时忽略“” 的左侧
.\detours.cpp(156): warning C4456: “pbNew”的声明隐藏了上一个本地声明
.\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: 参见“pbNew”的声明
.\detours.cpp(163): warning C4456: “pbNew”的声明隐藏了上一个本地声明
.\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: 参见“pbNew”的声明
.\detours.cpp(1263): warning C4456: “o”的声明隐藏了上一个本地声明
.\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: 参见“o”的声明
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.EXE"”: 返回代码“0x2”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"”: 返回代码“0x2”
Stop.

D:\Software\DetourExpress30>
①使用文档编辑器打开 D:\Software\DetourExpress30\src\Makefile文件,搜索找到下面一行

CFLAGS=/W4 /WX /Zi /MTd /Gy /Gm- /Zl /Od /DDETOURS_BITS=$(DETOURS_BITS)
将这一句中的 /WX 删除,如下

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


②使用文档编辑器打开D:\Software\DetourExpress30\samples\common.mak 搜索找到下面一行

<pre name="code" class="plain">CFLAGS=/nologo /Zi $(CLIB) /Gm- /W4 /WX /Od /DDETOURS_BITS=$(DETOURS_BITS)




同样删除 /WX

CFLAGS=/nologo /Zi $(CLIB) /Gm- /W4 /Od /DDETOURS_BITS=$(DETOURS_BITS)


然后运行nmake

就会编译成功

打开D:\Software\DetourExpress30\lib.X86 已经生成detours.lib文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: