VS2015:迁移到X64 Middle Compiler后,存在未解决的smbols

时间:2018-10-02 05:18:50

标签: c++ visual-studio-2015

我正在使用Visual Studio 2015从X86迁移到X64

对于MIDL编译器,我有一个非常简单的IDL

import "unknwn.IDL";
import "objidl.IDL";
import "ICmNamedObject.idl";
import "ipositio.idl";

[ uuid (96c63c60-24f6-11d0-8f8c-0020af9033c2), object, pointer_default(unique) ]
interface ICmMuxServer : IUnknown {
  HRESULT GetSigma        ( [out] ICmNamedObject** sigma );
  HRESULT GetDecMuxes     ( [out] ICMPosition** decmuxes );
  HRESULT updateMuxServer ( [out] BSTR* excStr, [in,string] LPSTR name, [in] ICmNamedObject* sigma, [in] DWORD count, [in,size_is(count)] ICmNamedObject** decmuxes );
}

此IDL的存根源为

#include "AStdComp.h"

#pragma warning ( disable : 4232 ) // warning C4232: nonstandard extension used : 'pfnAllocate' : address of dllimport 'NdrOleAllocate' is not static, identity not guaranteed

#include "Gen/ICmNamedObject_p.c"

#include "Gen/ICmNamedObject_i.c"

问题是当我编译项目时出现错误
严重性代码说明项目文件行抑制状态 错误LNK2001无法解析的外部符号ICmNamedObject_ProxyFileInfo NmsCmCommon D:\ Home \ Atiras \ V77Ma_64Bit_Branch001 \ Src \ Cm \ NmsCmCommon \ NmsCmCommonPs.obj 1
NmsCmCommonP使用了另一个IDL

// cannot use precompiled header file!
#undef _WINDLL
#include "AStdComp.h"

#pragma comment(lib, "rpcrt4.lib")

#define TOOLLIBPROXY_UPDIRS 3
#include "ToolLibProxy.inc.h"

#define REGISTER_PROXY_DLL

// the following content is taken from the files *_d.c (ex: "NmsTaskDbSv_d.c")

#define PROXY_DELEGATION

#include <rpcproxy.h>

#ifdef __cplusplus
extern "C"   {
#endif

EXTERN_PROXY_FILE( IAssociated )
EXTERN_PROXY_FILE( IComPort )
EXTERN_PROXY_FILE( ICmConnection )
EXTERN_PROXY_FILE( IEdit )
EXTERN_PROXY_FILE( IIndex )
EXTERN_PROXY_FILE( ILeasedL )
EXTERN_PROXY_FILE( IMaia )
EXTERN_PROXY_FILE( IMeridian )
EXTERN_PROXY_FILE( IModemType )
EXTERN_PROXY_FILE( IModem )
EXTERN_PROXY_FILE( ICmMuxServer )
EXTERN_PROXY_FILE( ICmNamedObject )
EXTERN_PROXY_FILE( INode )
EXTERN_PROXY_FILE( IOverlay )
EXTERN_PROXY_FILE( ICmPort )
EXTERN_PROXY_FILE( IPositio )
EXTERN_PROXY_FILE( IQueuedConnection )
EXTERN_PROXY_FILE( IRcd )
EXTERN_PROXY_FILE( ISigma )
EXTERN_PROXY_FILE( ISinglePort )
EXTERN_PROXY_FILE( ITcpServer )
EXTERN_PROXY_FILE( ICmTerminalServer )
EXTERN_PROXY_FILE( ITopolog )
EXTERN_PROXY_FILE( ICmTty )

PROXYFILE_LIST_START
/* Start of list */
  REFERENCE_PROXY_FILE( IAssociated ),
  REFERENCE_PROXY_FILE( IComPort ),
  REFERENCE_PROXY_FILE( ICmConnection ),
  REFERENCE_PROXY_FILE( IEdit ),
  REFERENCE_PROXY_FILE( IIndex ),
  REFERENCE_PROXY_FILE( ILeasedL ),
  REFERENCE_PROXY_FILE( IMaia ),
  REFERENCE_PROXY_FILE( IMeridian ),
  REFERENCE_PROXY_FILE( IModemType ),
  REFERENCE_PROXY_FILE( IModem ),
  REFERENCE_PROXY_FILE( ICmMuxServer ),
  REFERENCE_PROXY_FILE( ICmNamedObject ),
  REFERENCE_PROXY_FILE( INode ),
  REFERENCE_PROXY_FILE( IOverlay ),
  REFERENCE_PROXY_FILE( ICmPort ),
  REFERENCE_PROXY_FILE( IPositio ),
  REFERENCE_PROXY_FILE( IQueuedConnection ),
  REFERENCE_PROXY_FILE( IRcd ),
  REFERENCE_PROXY_FILE( ISigma ),
  REFERENCE_PROXY_FILE( ISinglePort ),
  REFERENCE_PROXY_FILE( ITcpServer ),
  REFERENCE_PROXY_FILE( ICmTerminalServer ),
  REFERENCE_PROXY_FILE( ITopolog ),
  REFERENCE_PROXY_FILE( ICmTty ),
/* End of list */
PROXYFILE_LIST_END

#pragma warning ( disable : 4100 ) // 'lpvReserved' : unreferenced formal parameter
DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )

#ifdef __cplusplus
}  /*extern "C" */
#endif

我想MIDL编译器创建了X86代码,该代码导致此链接错误。当我查看生成的文件时,它们似乎是为X86和Win32生成的

/* this ALWAYS GENERATED file contains the proxy stub code */


 /* File created by MIDL compiler version 8.00.0603 */
/* at Mon Oct 01 14:19:52 2018
 */
/* Compiler settings for D:\Home\Atiras\V77Ma_64Bit_Branch001\Src\Cm\NmsCmCommon\ICmNamedObject.idl:
    Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603 
    protocol : dce , ms_ext, c_ext, robust
    error checks: none
    VC __declspec() decoration level: 
         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
         DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING(  ) */

#if !defined(_M_IA64) && !defined(_M_AMD64) && !defined(_ARM_)


#pragma warning( disable: 4049 )  /* more than 64k source lines */
#if _MSC_VER >= 1200
#pragma warning(push)
#endif

#pragma warning( disable: 4211 )  /* redefine extern to static */
#pragma warning( disable: 4232 )  /* dllimport identity*/
#pragma warning( disable: 4024 )  /* array to pointer mapping*/
#pragma warning( disable: 4152 )  /* function/data pointer conversion in expression */
#pragma warning( disable: 4100 ) /* unreferenced arguments in x86 call */

#pragma optimize("", off ) 

#define USE_STUBLESS_PROXY


/* verify that the <rpcproxy.h> version is high enough to compile this file*/
#ifndef __REDQ_RPCPROXY_H_VERSION__
#define __REQUIRED_RPCPROXY_H_VERSION__ 475
#endif


#include "rpcproxy.h"
#ifndef __RPCPROXY_H_VERSION__
#error this stub requires an updated version of <rpcproxy.h>
#endif /* __RPCPROXY_H_VERSION__ */


#include "ICmNamedObject.h"

#define TYPE_FORMAT_STRING_SIZE   11                                
#define PROC_FORMAT_STRING_SIZE   73                                
#define EXPR_FORMAT_STRING_SIZE   1                                 
#define TRANSMIT_AS_TABLE_SIZE    0            
#define WIRE_MARSHAL_TABLE_SIZE   0            

typedef struct _ICmNamedObject_MIDL_TYPE_FORMAT_STRING
    {
    short          Pad;
    unsigned char  Format[ TYPE_FORMAT_STRING_SIZE ];
    } ICmNamedObject_MIDL_TYPE_FORMAT_STRING;

typedef struct _ICmNamedObject_MIDL_PROC_FORMAT_STRING
    {
    short          Pad;
    unsigned char  Format[ PROC_FORMAT_STRING_SIZE ];
    } ICmNamedObject_MIDL_PROC_FORMAT_STRING;

typedef struct _ICmNamedObject_MIDL_EXPR_FORMAT_STRING
    {
    long          Pad;
    unsigned char  Format[ EXPR_FORMAT_STRING_SIZE ];
    } ICmNamedObject_MIDL_EXPR_FORMAT_STRING;


static const RPC_SYNTAX_IDENTIFIER  _RpcTransferSyntax = 
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}};


extern const ICmNamedObject_MIDL_TYPE_FORMAT_STRING ICmNamedObject__MIDL_TypeFormatString;
extern const ICmNamedObject_MIDL_PROC_FORMAT_STRING ICmNamedObject__MIDL_ProcFormatString;
extern const ICmNamedObject_MIDL_EXPR_FORMAT_STRING ICmNamedObject__MIDL_ExprFormatString;


extern const MIDL_STUB_DESC Object_StubDesc;


extern const MIDL_SERVER_INFO ICmNamedObject_ServerInfo;
extern const MIDL_STUBLESS_PROXY_INFO ICmNamedObject_ProxyInfo;



#if !defined(__RPC_WIN32__)
#error  Invalid build platform for this stub.
#endif

#if !(TARGET_IS_NT50_OR_LATER)
#error You need Windows 2000 or later to run this stub because it uses these features:
#error   /robust command line switch.
#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems.
#error This app will fail with the RPC_X_WRONG_STUB_VERSION error.
#endif


static const ICmNamedObject_MIDL_PROC_FORMAT_STRING ICmNamedObject__MIDL_ProcFormatString =
    {
        0,
        {

    /* Procedure GetName */

            0x33,       /* FC_AUTO_HANDLE */
            0x6c,       /* Old Flags:  object, Oi2 */
/*  2 */    NdrFcLong( 0x0 ),   /* 0 */
/*  6 */    NdrFcShort( 0x3 ),  /* 3 */
/*  8 */    NdrFcShort( 0xc ),  /* x86 Stack size/offset = 12 */
/* 10 */    NdrFcShort( 0x0 ),  /* 0 */
/* 12 */    NdrFcShort( 0x8 ),  /* 8 */
/* 14 */    0x45,       /* Oi2 Flags:  srv must size, has return, has ext, */
            0x2,        /* 2 */
/* 16 */    0x8,        /* 8 */
            0x1,        /* Ext Flags:  new corr desc, */
/* 18 */    NdrFcShort( 0x0 ),  /* 0 */
/* 20 */    NdrFcShort( 0x0 ),  /* 0 */
/* 22 */    NdrFcShort( 0x0 ),  /* 0 */

    /* Parameter name */

/* 24 */    NdrFcShort( 0x2013 ),   /* Flags:  must size, must free, out, srv alloc size=8 */
/* 26 */    NdrFcShort( 0x4 ),  /* x86 Stack size/offset = 4 */
/* 28 */    NdrFcShort( 0x2 ),  /* Type Offset=2 */

    /* Return value */

/* 30 */    NdrFcShort( 0x70 ), /* Flags:  out, return, base type, */
/* 32 */    NdrFcShort( 0x8 ),  /* x86 Stack size/offset = 8 */
/* 34 */    0x8,        /* FC_LONG */
            0x0,        /* 0 */

    /* Procedure GetIdRefString */

/* 36 */    0x33,       /* FC_AUTO_HANDLE */
            0x6c,       /* Old Flags:  object, Oi2 */
/* 38 */    NdrFcLong( 0x0 ),   /* 0 */
/* 42 */    NdrFcShort( 0x4 ),  /* 4 */
/* 44 */    NdrFcShort( 0xc ),  /* x86 Stack size/offset = 12 */
/* 46 */    NdrFcShort( 0x0 ),  /* 0 */
/* 48 */    NdrFcShort( 0x8 ),  /* 8 */
/* 50 */    0x45,       /* Oi2 Flags:  srv must size, has return, has ext, */
            0x2,        /* 2 */
/* 52 */    0x8,        /* 8 */
            0x1,        /* Ext Flags:  new corr desc, */
/* 54 */    NdrFcShort( 0x0 ),  /* 0 */
/* 56 */    NdrFcShort( 0x0 ),  /* 0 */
/* 58 */    NdrFcShort( 0x0 ),  /* 0 */

    /* Parameter oidStr */

/* 60 */    NdrFcShort( 0x2013 ),   /* Flags:  must size, must free, out, srv alloc size=8 */
/* 62 */    NdrFcShort( 0x4 ),  /* x86 Stack size/offset = 4 */
/* 64 */    NdrFcShort( 0x2 ),  /* Type Offset=2 */

    /* Return value */

/* 66 */    NdrFcShort( 0x70 ), /* Flags:  out, return, base type, */
/* 68 */    NdrFcShort( 0x8 ),  /* x86 Stack size/offset = 8 */
/* 70 */    0x8,        /* FC_LONG */
            0x0,        /* 0 */

            0x0
        }
    };

static const ICmNamedObject_MIDL_TYPE_FORMAT_STRING ICmNamedObject__MIDL_TypeFormatString =
    {
        0,
        {
            NdrFcShort( 0x0 ),  /* 0 */
/*  2 */    
            0x11, 0x14, /* FC_RP [alloced_on_stack] [pointer_deref] */
/*  4 */    NdrFcShort( 0x2 ),  /* Offset= 2 (6) */
/*  6 */    
            0x13, 0x8,  /* FC_OP [simple_pointer] */
/*  8 */    
            0x22,       /* FC_C_CSTRING */
            0x5c,       /* FC_PAD */

            0x0
        }
    };


/* Object interface: IUnknown, ver. 0.0,
   GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */


/* Object interface: ICmNamedObject, ver. 0.0,
   GUID={0x96c63c60,0x24f6,0x11d0,{0x8f,0x8c,0x00,0x20,0xaf,0x90,0x33,0xbd}} */

#pragma code_seg(".orpc")
static const unsigned short ICmNamedObject_FormatStringOffsetTable[] =
    {
    0,
    36
    };

static const MIDL_STUBLESS_PROXY_INFO ICmNamedObject_ProxyInfo =
    {
    &Object_StubDesc,
    ICmNamedObject__MIDL_ProcFormatString.Format,
    &ICmNamedObject_FormatStringOffsetTable[-3],
    0,
    0,
    0
    };


static const MIDL_SERVER_INFO ICmNamedObject_ServerInfo = 
    {
    &Object_StubDesc,
    0,
    ICmNamedObject__MIDL_ProcFormatString.Format,
    &ICmNamedObject_FormatStringOffsetTable[-3],
    0,
    0,
    0,
    0};
CINTERFACE_PROXY_VTABLE(5) _ICmNamedObjectProxyVtbl = 
{
    &ICmNamedObject_ProxyInfo,
    &IID_ICmNamedObject,
    IUnknown_QueryInterface_Proxy,
    IUnknown_AddRef_Proxy,
    IUnknown_Release_Proxy ,
    (void *) (INT_PTR) -1 /* ICmNamedObject::GetName */ ,
    (void *) (INT_PTR) -1 /* ICmNamedObject::GetIdRefString */
};

const CInterfaceStubVtbl _ICmNamedObjectStubVtbl =
{
    &IID_ICmNamedObject,
    &ICmNamedObject_ServerInfo,
    5,
    0, /* pure interpreted */
    CStdStubBuffer_METHODS
};

static const MIDL_STUB_DESC Object_StubDesc = 
    {
    0,
    NdrOleAllocate,
    NdrOleFree,
    0,
    0,
    0,
    0,
    0,
    ICmNamedObject__MIDL_TypeFormatString.Format,
    0, /* -error bounds_check flag */
    0x50002, /* Ndr library version */
    0,
    0x800025b, /* MIDL Version 8.0.603 */
    0,
    0,
    0,  /* notify & notify_flag routine table */
    0x1, /* MIDL flag */
    0, /* cs routines */
    0,   /* proxy/server info */
    0
    };

const CInterfaceProxyVtbl * const _ICmNamedObject_ProxyVtblList[] = 
{
    ( CInterfaceProxyVtbl *) &_ICmNamedObjectProxyVtbl,
    0
};

const CInterfaceStubVtbl * const _ICmNamedObject_StubVtblList[] = 
{
    ( CInterfaceStubVtbl *) &_ICmNamedObjectStubVtbl,
    0
};

PCInterfaceName const _ICmNamedObject_InterfaceNamesList[] = 
{
    "ICmNamedObject",
    0
};


#define _ICmNamedObject_CHECK_IID(n)    IID_GENERIC_CHECK_IID( _ICmNamedObject, pIID, n)

int __stdcall _ICmNamedObject_IID_Lookup( const IID * pIID, int * pIndex )
{

    if(!_ICmNamedObject_CHECK_IID(0))
        {
        *pIndex = 0;
        return 1;
        }

    return 0;
}

const ExtendedProxyFileInfo ICmNamedObject_ProxyFileInfo = 
{
    (PCInterfaceProxyVtblList *) & _ICmNamedObject_ProxyVtblList,
    (PCInterfaceStubVtblList *) & _ICmNamedObject_StubVtblList,
    (const PCInterfaceName * ) & _ICmNamedObject_InterfaceNamesList,
    0, /* no delegation */
    & _ICmNamedObject_IID_Lookup, 
    1,
    2,
    0, /* table of [async_uuid] interfaces */
    0, /* Filler1 */
    0, /* Filler2 */
    0  /* Filler3 */
};
#pragma optimize("", on )
#if _MSC_VER >= 1200
#pragma warning(pop)
#endif


#endif /* !defined(_M_IA64) && !defined(_M_AMD64) && !defined(_ARM_) */



respektive




/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */

/* link this file in with the server and any clients */


 /* File created by MIDL compiler version 8.00.0603 */
/* at Mon Oct 01 14:19:52 2018
 */
/* Compiler settings for D:\Home\Atiras\V77Ma_64Bit_Branch001\Src\Cm\NmsCmCommon\ICmNamedObject.idl:
    Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603 
    protocol : dce , ms_ext, c_ext, robust
    error checks: none
    VC __declspec() decoration level: 
         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
         DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING(  ) */

#pragma warning( disable: 4049 )  /* more than 64k source lines */


#ifdef __cplusplus
extern "C"{
#endif 


#include <rpc.h>
#include <rpcndr.h>

#ifdef _MIDL_USE_GUIDDEF_

#ifndef INITGUID
#define INITGUID
#include <guiddef.h>
#undef INITGUID
#else
#include <guiddef.h>
#endif

#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
        DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)

#else // !_MIDL_USE_GUIDDEF_

#ifndef __IID_DEFINED__
#define __IID_DEFINED__

typedef struct _IID
{
    unsigned long x;
    unsigned short s1;
    unsigned short s2;
    unsigned char  c[8];
} IID;

#endif // __IID_DEFINED__

#ifndef CLSID_DEFINED
#define CLSID_DEFINED
typedef IID CLSID;
#endif // CLSID_DEFINED

#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
        const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}

#endif !_MIDL_USE_GUIDDEF_

MIDL_DEFINE_GUID(IID, IID_ICmNamedObject,0x96c63c60,0x24f6,0x11d0,0x8f,0x8c,0x00,0x20,0xaf,0x90,0x33,0xbd);

#undef MIDL_DEFINE_GUID

#ifdef __cplusplus
}
#endif

在项目中,我找不到用于生成x64代码而不是X86代码的任何设置

2 个答案:

答案 0 :(得分:0)

我可以通过调整Midl编译器选项来解决此问题,我实际上使用了以下选项

MIDL / Oicf / env x64 / x64 / protocol all / error none /I......\BinDll\Ms\Include / out“ $(IntDir).. \ Gen” / I“%(RootDir) %(目录)。” / dlldata“%(文件名)_d.c” / iid“%(文件名)_i.c” / h“%(文件名).h” / tlb“%(文件名).tlb” /代理“%(文件名)_p .c“”%(FullPath)“

但是现在我还有其他一些未解决的Sympols

NmsCmCommon.exp:错误LNK2001:无法解析的外部符号_DllCanUnloadNow @ 0 NmsCmCommon.exp:错误LNK2001:无法解析的外部符号_DllGetClassObject @ 12 NmsCmCommon.exp:错误LNK2001:无法解析的外部符号_DllRegisterServer @ 0 NmsCmCommon.exp:错误LNK2001:无法解析的外部符号_DllUnregisterServer @ 0

答案 1 :(得分:0)

我可以通过删除以下注释来解决问题

实用注释(链接器,“ / EXPORT:DllCanUnloadNow = _DllCanUnloadNow @ 0,PRIVATE”)

注释注释(链接器,“ / EXPORT:DllGetClassObject = _DllGetClassObject @ 12,PRIVATE”)

实用注释(链接器,“ / EXPORT:DllRegisterServer = _DllRegisterServer @ 0,PRIVATE”)

实用注释(链接器,/ EXPORT:DllUnregisterServer = _DllUnregisterServer @ 0,PRIVATE“)