【问题标题】:Compilation of detours on vs2012 (Windows 8.1)vs2012上的弯路编译(Windows 8.1)
【发布时间】:2014-03-02 17:41:08
【问题描述】:

使用 Visual Studio 2012 命令工具(即在“本机工具命令提示符”命令控制台中)我已运行 vcvars32.bat,并导航到 *c:\program file(x86)\ Microsoft Research\Detours Express 3.0*。

在此目录中运行 nmake 时,它​​开始成功构建,但随后退出并出现错误:

cl /nologo /nologo /Zi /MT /Gm- /W4 /WX /Od /DDETOURS_BITS=32 /I..\..\include /Gs /DDETOURS_X86=1 /DDETOURS_32BIT=1 /D_X86_ /DDETOURS_OPTION_BITS=64 /Fdobj.X86\vc.pdb /Foobj.X86\member.obj /c member.cpp

member.cpp
member.cpp(88) : error C2440: 'type cast' : cannot convert from 'void (__thiscall CMember::* )(void)' to 'PBYTE &'
Reason: cannot convert from 'overloaded-function' to 'PBYTE *'
There is no context in which this conversion is possible 

member.cpp(90) : error C2440: 'type cast' : cannot convert from 'void (__thiscall CDetour::* )(void)' to 'PBYTE &'
Reason: cannot convert from 'overloaded-function' to 'PBYTE *'
There is no context in which this conversion is possible

// error repeated member.cpp lines 105, 120, 122.

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

不确定如何继续处理此错误。我也尝试过:

set DETOURS_TARGET_PROCESSOR=X86

然后是“nmake clean”,然后是一个新的“nmake”——但这会导致同样的错误。

如标题中所述,我正在使用 vs2012 在 Windows 8.1 机器 (x64) 上构建。

谢谢

【问题讨论】:

    标签: visual-studio-2012 nmake detours


    【解决方案1】:

    wibble 提供的解决方案对我不起作用,但由于编译器错误仅在编译示例时发生(在成功编译 MS Detours 之后),如果您只想使用该库,则错误不再重要。

    【讨论】:

    • 我只是 ctrl+f'd 用member 和 /samples/Makefile 中的以下构建命令删除每一行
    【解决方案2】:

    好的,所以我解决了它,所以我想如果其他人觉得它有用,我会发布答案。

    我已经通过反复试验来做到这一点,所以我仍然希望有人来解释为什么/什么是这个错误以及导致它的原因等。

    然而,这里是我为了让它编译而做出的改变:

    #if (_MSC_VER < 1310)
        pfTarget = CMember::Target;
        pfMine = CDetour::Mine_Target;
    
        Verify("CMember::Target", *(PBYTE*)&pfTarget);
        Verify("*CDetour::Real_Target", *(&(PBYTE&)CDetour::Real_Target));
        Verify("CDetour::Mine_Target", *(PBYTE*)&pfMine);
    #else
        //Verify("CMember::Target", (PBYTE)(&(PBYTE&)CMember::Target));
        //Verify("*CDetour::Real_Target", *(&(PBYTE&)CDetour::Real_Target));
        //Verify("CDetour::Mine_Target", (PBYTE)(&(PBYTE&)CDetour::Mine_Target));
    
        pfTarget = &CMember::Target;
        pfMine = &CDetour::Mine_Target;
    
        Verify("CMember::Target", *(PBYTE*)&pfTarget);
        Verify("*CDetour::Real_Target", *(&(PBYTE&)CDetour::Real_Target));
        Verify("CDetour::Mine_Target", *(PBYTE*)&pfMine);
    #endif
    

    我的更改在第二半'else'语句中,原始代码已被注释掉。

    对于每个错误(原始问题中的相关行号)-我注释掉了那里的内容,从第一半“if”部分复制并粘贴,但从“pfTarget = CMember::Target;”更改为“pfTarget = &CMember::Target;"(基于编译器的指令)。

    似乎是两个不同的问题,首先在 if/else 块中采取了错误的路径(_MSC_VER 应该设置在某个地方,不是吗?)其次,从 CMember::Target 到 &CMember::Target 所需的更改。

    谢谢

    【讨论】:

    • 我们也可以将所有的“#if (_MSC_VER
    猜你喜欢
    • 2016-04-04
    • 1970-01-01
    • 2014-03-19
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 2014-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多