我有一個包含許多dll和exe項目的應用程序。我正在移植到64位版本,幾乎一切正常。但是,我有一個exe項目無法在64位配置中正確構建。奇怪的是,它不會從IDE構建命令構建。如果我打開一個64位的VS命令窗口並使用msbuild構建,它確實可以構建。Visual Studio 2010 IDE沒有目標架構錯誤IDE 64位版本
我看了一些其他類似的問題和答案,通常指的是一個額外的(或缺少)windows.h包括但很難確定這是否是同一件事。我已經嘗試了包含的不同組合,但我沒有看到明確的問題。
我可以在VS IDE中構建項目作爲32位exe 我無法在VS IDE中將項目構建爲64位exe 我可以在64位命令窗口中構建項目,如下所示:一個64位的exe
我有_WIN64和_AMD64定義爲預處理器定義。
如果我使編譯器選項,以顯示包括,我看到:
1> Note: including file: c:\dev\projects\myapp\myproject.root\myproject\stdafx.h 1> Note: including file: c:\dev\projects\myapp\myproject.root\myproject\targetver.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\SDKDDKVer.h 1> Note: including file: c:\dev\projects\myapp\myproject.root\myproject\resource.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlbase.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atldef.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlrc.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\errno.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\sal.h 1> Note: including file: c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(27): error C2371: 'size_t' : redefinition; different basic types 1> predefined C++ types (compiler internal)(19) : see declaration of 'size_t' 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vadefs.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\malloc.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdlib.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\limits.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdbg.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winsock2.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windows.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\excpt.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdarg.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windef.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\specstrings.h 1> Note: including file: c:\program files (x86)\microsoft sdks\windows\v7.0a\include\sal_supp.h 1> Note: including file: c:\program files (x86)\microsoft sdks\windows\v7.0a\include\specstrings_supp.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\specstrings_strict.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\specstrings_undef.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\driverspecs.h 1> Note: including file: c:\program files (x86)\microsoft sdks\windows\v7.0a\include\sdv_driverspecs.h 1> Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\kernelspecs.h 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(135): fatal error C1189: #error : "No Target Architecture"
有什麼建議?
在項目設置中,您無需定義'_WIN64'或'_AMD64'您只需將項目平臺設置爲x64並將連接器目標機器設置爲machine64即可。 – VTT
有趣。我刪除了這些定義,現在一切編譯正確,但我得到一個鏈接器錯誤:「致命錯誤LNK1112:模塊機器類型'X86'與目標機器類型'x64'」衝突。我有'x64'作爲平臺,連接器設置設置爲機器類型X64。 – Ken
也許你對一個翻譯單元有不同的設置?例如對於預編譯頭文件.cpp? – VTT