首页 > 解决方案 > 为 64 位编译 Microsoft Detours

问题描述

detours软件包声称支持64-bit,但我没有看到编译64-bit二进制文件的方法:

绕行 32 位和 64 位进程

使用nmake all只编译32-bit东西:

>dir
 Volume in drive D is Volume
 Volume Serial Number is XXXX-XXXX

 Directory of D:\Detours

06/21/2018  03:46 PM    <DIR>          .
06/21/2018  03:46 PM    <DIR>          ..
06/23/2018  08:13 PM    <DIR>          bin.X86
06/20/2017  09:03 AM             5,105 CREDITS.TXT
06/22/2017  03:06 PM                31 Detours Version 3.0 Build_343
10/19/2016  12:06 PM           113,685 Detours.chm
06/23/2018  08:12 PM    <DIR>          include
06/23/2018  08:12 PM    <DIR>          lib.X86
10/29/2015  02:19 PM             7,144 LICENSE.RTF
12/21/2016  01:22 PM             1,851 Makefile
06/22/2017  03:06 PM            14,961 README.TXT
06/21/2018  03:04 PM    <DIR>          samples
06/23/2018  08:12 PM    <DIR>          src
10/29/2015  02:19 PM             4,841 system.mak
06/22/2017  03:06 PM                31 VERSION.TXT

nmake size64命令无效。

如果我在我的项目中使用配置为生成 a的库(lib.X86文件夹),我会收到相应的错误并且它不会构建:Visual Studio C++64-bit DLL

library machine type 'x86' conflicts with target machine type 'x64'

将文件夹重命名lib.X86lib.X64也不起作用。

我怎样才能让它在64-bit环境中工作还是不可能?

标签: c++windowsvisual-studiodetours

解决方案


看来您必须将目标处理器设置为 64 位,然后编译. 工作批处理 ( .bat) 脚本可能类似于以下内容(取决于您的 Visual Studio 安装):

SET DETOURS_TARGET_PROCESSOR=X64
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
NMAKE

有了这个,64-bit二进制文件应该可以成功编译。


推荐阅读