从x86更改为x64后的链接器错误

问题描述 投票:0回答:1

[当我尝试构建项目gwmeta时收到此错误:

Build started 20.03.2020 10:54:54.
     1>Project "C:\Users\Yil\Desktop\EP2000\Rel19-x64\gwmeta\gwmeta.vcxproj" on node 2 (Build target(s)).
     1>Link:
         C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.dll" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Program Files (x86)\Visual Leak Detector\lib\Win32" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.pdb" /SUBSYSTEM:WINDOWS /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.lib" /MACHINE:X64 /DLL x64\Debug\gwmeta.res
         x64\Debug\gwmeta.obj
         x64\Debug\winmeta.obj
         "C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdbase.lib"
         "C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdcore.lib"
            Creating library C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.lib and object C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.exp
     1>winmeta.obj : error LNK2019: unresolved external symbol "int __cdecl MetaEnumProc(void *,struct tagHANDLETABLE *,struct tagMETARECORD *,int,__int64)" (?MetaEnumProc@@YAHPEAXPEAUtagHANDLETABLE@@PEAUtagMETARECORD@@H_J@Z) referenced in function "protected: void __cdecl MetaFile::GetMetaFileAndEnum(void *)" (?GetMetaFileAndEnum@MetaFile@@IEAAXPEAX@Z)
     1>C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.dll : fatal error LNK1120: 1 unresolved externals
     1>Done Building Project "C:\Users\Yil\Desktop\EP2000\Rel19-x64\gwmeta\gwmeta.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:00.19

这是错误的来源:

void MetaFile::GetMetaFileAndEnum(HDC hDC)
{

    // if there is a valid handle to a metafile begin enumerating it
    if (hMF)
    {
#ifdef __WIN16__
        FARPROC lpprocEnumMF = MakeProcInstance((FARPROC)MetaEnumProc,
                                                GwInstance());
        EnumMetaFile(hDC, hMF, (FARPROC)lpprocEnumMF, (LPARAM) this);
        FreeProcInstance ((FARPROC) lpprocEnumMF);
#else

        if (bEnhanced)
        {
            RECT r;
            GetClientRect (WindowFromDC(hDC),&r);
            EnumEnhMetaFile(hDC, hMF, (ENHMFENUMPROC)EnhMetaEnumProc, (LPVOID) this,&r);
        }
        else
            EnumMetaFile(hDC, hMF, static_cast<MFENUMPROC>(MetaEnumProc), (LPARAM) this);
#endif

    }
    else
    {
        GwCore::warning (GwERR_METAFILE_FAILED,"GetMetaFile failed");
    }
}

删除行EnumMetaFile(hDC, hMF, static_cast<MFENUMPROC>(MetaEnumProc), (LPARAM) this);它建立。 MetaEnumProc显然是这里的问题。

我注意到另一件事:

Linker error

winmeta.obj的红色字段中的路径错误。 winmeta.obj在.. \ gwmeta \ x64 \ Debug \ winmeta.obj中而不是在.. \ gwmeta \ winmeta.obj

我所有的项目都设置为x64。我还多次重建和清理解决方案。我正在使用VS2012,我也尝试过使用VS2019进行构建,但问题仍然存在。

如果有帮助,这是链接器->命令行视图:

    /OUT:"C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.dll" /MANIFEST /NXCOMPAT 
/PDB:"C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.pdb" /DYNAMICBASE "kernel32.lib" 
"user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib"
 "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "C:\Users\Yil\Desktop\EP2000\Rel19-
x64\x64\Debug\gdbase.lib" "C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdcore.lib" 
/IMPLIB:"C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.lib" /DEBUG /DLL /MACHINE:X64 
/INCREMENTAL /PGD:"C:\Users\Yil\Desktop\EP2000\Rel19-x64\x64\Debug\gdmeta.pgd" /SUBSYSTEM:WINDOWS
 /MANIFESTUAC:"level='asInvoker' uiAccess='false'" 
/ManifestFile:"x64\Debug\gdmeta.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO 
/LIBPATH:"C:\Program Files (x86)\Visual Leak Detector\lib\Win32" /TLBID:1 

MetaEnumProc与上面的winmeta.cxx中的代码在同一文件中定义

#ifdef __WIN16__
int FAR PASCAL __export MetaEnumProc(HDC hDC, LPHANDLETABLE lpHTable,
                                        LPMETARECORD lpMFR, int nObj,
                                        BYTE FAR* lpClientData)
#else
int CALLBACK  MetaEnumProc(HDC hDC, LPHANDLETABLE lpHTable,
        LPMETARECORD lpMFR, int nObj,
        LPARAM UNUSED (lpClientData))
#endif
{

    if ((lpMFR->rdFunction == 0x0234) &&
        (lpMFR->rdParm[0] == 0))
    {
         lpMFR->rdParm[0] = 1;
    }


    // Play the record
    PlayMetaFileRecord(hDC, lpHTable, lpMFR, (WORD)nObj);


    // if we made it this far then continue the enumeration
    return(1);

}

以前曾在x32中工作,但程序在x64上有问题。

c++ visual-studio-2012 64-bit x86-64 linker-errors
1个回答
0
投票
我发现了问题:

A MFENUMPROC希望第三个参数为METARECORD *,但LPMETARECORD与之不完全相同; LPMETARECORD具有__aligned。所以我改变了这个

© www.soinside.com 2019 - 2024. All rights reserved.