visual studio編譯錯誤集(轉)

來源:互聯網
上載者:User

標籤:

1、error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

在項目屬性->Configration Properties->C/C++->Command Line頁面的Additional Options中加入/wd4430

 

2、error MSB3073: The command regsvr32 /s /c 解決辦法  

 

最近將VC2002 代碼移植到VC2010,出現編譯錯誤:

1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: The command "regsvr32 /s /c "D:\VC++Prj\source code\zutai\cha06\Meter\.\Debug\Meter.dll" 

1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: echo regsvr32 exec. time > ".\Debug\regsvr32.trg"

1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: :VCEnd" exited with code 3.

英文版處理辦法: 

Project->Configuration Properties->General->Target Extension設定為.ocx 或者.dll

Project->Configuration Properties->Linkerl->General ->Output File設定為$(OutDir)$(ProjectName)$(TargetExt)

中文版處理辦法: 

在項目上點右鍵,選擇“屬性”->“配置屬性”->“常規”->“目標檔案副檔名”,設定為.ocx 或者.dll

在項目上點右鍵,選擇“屬性”->“配置屬性”->“連結器”->“ 常規 ”->“輸出檔案”,設定為$(OutDir)$(ProjectName)$(TargetExt)

3、altdef.h 都是這個檔案裡的定義

#ifndef ATLTRY
#define ATLTRY(x) ATLTRYALLOC(x)
#endif //ATLTRY

出問題的都是這個宏
ATLTRY(szKey = new TCHAR[cbKey]);
ATLTRY(pszW.Allocate(_convert));
                  ATLTRY(szReg.Allocate(dwSize + 1));


1>FilterImageGrabber.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(954) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(954) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(970) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(970) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(995) : error C2712: 無法在要求對象展開的函數中使用 __try
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(1008) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(1008) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(1024) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(1024) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(1190) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(1190) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(107) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(107) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(113) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(113) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(423) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(423) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(587) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(587) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(901) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(901) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(971) : error C2059: 語法錯誤 : “catch”
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\statreg.h(971) : error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)

 

原來是工程屬性-〉預定義裡的問題,它在裡面定義了try=_try,把這個刪除就OK了

 

4、

Error MSB3073 exited with code 3

The issue that causes "Error MSB3073 exited with code 3" happens to be with the VALUE in the Outputs property under Project > Properties > Configuration Properties > Custom Build Step.

When I choose Edit for Outputs, a dialog box comes up.  I enter a value of "$(OutDir)\regsvr32.trg" in the upper textbox then click OK.  Now for some reason VS 2010 changes the display text to show "$(OutDir)\regsvr32.trg;%(Outputs)".  I‘m not sure why or if that is the cause of the problem.

However, I will get "Build Successful" if I change my Output value to "<inherit from parent or project defaults>" instead of choosing Edit and putting a value in.  No more Error MSB3073 exited with code 3.

I guess I can say this issue is resolved but I‘d like to know why/what causes this issue to begin with.

 

5、 fatal error LNK1181: cannot open input file‘largeint.lib‘
在linker->Input->Additional Dependencies中去掉largeint.lib

6、error MSB3073
最近將VC2002 代碼移植到VC2010,出現編譯錯誤:
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: The command "regsvr32 /s /c "D:\VC++Prj\source code\zutai\cha06\Meter\.\Debug\Meter.dll"
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: echo regsvr32 exec. time > ".\Debug\regsvr32.trg"
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: :VCEnd" exited with code 3.
英文版處理辦法: 
Project->Configuration Properties->General->Target Extension設定為.ocx 或者.dll
Project->Configuration Properties->Linkerl->General ->Output File設定為$(OutDir)$(ProjectName)$(TargetExt)
中文版處理辦法: 
在項目上點右鍵,選擇“屬性”->“配置屬性”->“常規”->“目標檔案副檔名”,設定為.ocx 或者.dll
在項目上點右鍵,選擇“屬性”->“配置屬性”->“連結器”->“ 常規 ”->“輸出檔案”,設定為$(OutDir)$(ProjectName)$(TargetExt)

 

 

7、error D8016: ‘/ZI‘ and ‘/GL‘ command-line options are incompatible

把Debug調試項改為/ZI /Od
Project Settings 項->C/C++ -> General

 

8、fatal error C1189: #error :  This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.

C/C++->Preprocessor->Preprocessor Definitions中的_WIN32_WINNT=0x0501改掉就可以了

 

9、C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlcomcli.h(1101): error C2059: syntax error : ‘catch‘
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlcomcli.h(1101): error C2143: syntax error : missing ‘;‘ before ‘{‘


C/C++->Preprocessor->Preprocessor Definitions 下面的try=__try去掉。

 

10、regsvr32無法註冊控制項
depends.exe開啟要註冊的控制項,找出這個控制項所依賴的檔案,缺少的檔案在網上下載下來,補上就可以了。

11、Graphedt.exe開啟後在工作列裡面有,但是點擊後無法顯示
開啟工作管理員,在應用程式中找到Graphedt.exe,右擊選擇最大化就可以看見程式了。

12、開機自啟動的註冊表目錄:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run下面,如果要開機啟動某個程式,只要把這個程式的路徑下載這個位置就可以了。

13、彈出對話方塊“attempt an unsupport operation!”,是因為被關聯的控制項的ID號和DoDataExchange中的控制項ID不同。

14、“Encountered an improper argument”,控制項被刪除了,但是還有代碼對控制項進行操作而導致的

 

15、C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winioctl.h(39): error C2374: ‘GUID_DEVINTERFACE_DISK‘ : redefinition; mult
重複包含了標頭檔“winioctl.h”


16、error C2059: syntax error : ‘catch‘
右鍵點擊工程名,properties->Configuration Properties->C/C++->PreProcessor->Preprocessor Definitions中將try=__try去掉即可!


17、>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: The command "regsvr32 /s /c D:\DirectShow及協議資料\DirectShow 實務精選+源碼\DirectShow實務精選源碼\SourceCodes\Chapter03\VODDemo\FilterNetReceiver\.\Release\FilterNetReceiver.dll
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: echo regsvr32 exec.time > D:\DirectShow及協議資料\DirectShow 實務精選+源碼\DirectShow實務精選源碼\SourceCodes\Chapter03\VODDemo\FilterNetReceiver\Release\FilterNetReceiver.trg
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: :VCEnd" exited with code 3.


18、error MSB3073
最近將VC2002 代碼移植到VC2010,出現編譯錯誤:
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: The command "regsvr32 /s /c "D:\VC++Prj\source code\zutai\cha06\Meter\.\Debug\Meter.dll"
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: echo regsvr32 exec. time > ".\Debug\regsvr32.trg"
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(183,5): error MSB3073: :VCEnd" exited with code 3.
英文版處理辦法: 
Project->Configuration Properties->General->Target Extension設定為.ocx 或者.dll
Project->Configuration Properties->Linkerl->General ->Output File設定為$(OutDir)$(ProjectName)$(TargetExt)
中文版處理辦法: 
在項目上點右鍵,選擇“屬性”->“配置屬性”->“常規”->“目標檔案副檔名”,設定為.ocx 或者.dll
在項目上點右鍵,選擇“屬性”->“配置屬性”->“連結器”->“ 常規 ”->“輸出檔案”,設定為$(OutDir)$(ProjectName)$(TargetExt)

這個仍然不能解決的話就將“屬性”->“配置屬性”->“連結器”->Custom Build Step中的Command line,Description,Outputs都選為預設值。即去除  不要自註冊。

 

 

19、error C2872: “CString”: 不明確的符號 
 
DUILIB與MFC的結合
會產生Crect等衝突。
解決方案:
1:在stdafx.h中添加
#if USE(DuiLib)
#define  CRect DuiLib::CRect
#define  CPoint DuiLib::CPoint
#define  CSize DuiLib::CSize
#else
#define CRect ::CRect
#define  CPoint ::CPoint
#define  CSize ::CSize
#endif
在用的地方定義DuiLib
2:將duilib中的crect工程中全部改名Cduirect等。全工程替換。不過一分鐘的事。
3:不在MFC中使用 using namespace Duilib 在使用duilib時都加上Duilib::Crect。


20、關於這樣的錯誤 libcpmtd.lib(string.obj) : error LNK2005: "public: void __thiscall


VC2008下 在一個動態庫工程中, 改成了編程靜態庫, 成功編譯, 但使用靜態庫的工程編譯時間就出現下面一堆串連錯誤.
 
經過尋找 解決方案如下:
說是因為 Project->C/C++->Code Generation->Runtime Library 這個選項,LIB和主程式(EXE)裡選擇的不一致引起的。後來改成一樣就好了。
 
把exe工程 改為/MTD(因為Lib工程是選擇/MTD的) 編譯還是錯誤
於是 把EXE工程和Lib工程都選擇為/MDD 成功編譯

 

 

21、error C2159: more than one storage class specified 

將vc6.0的工程轉換成vs2008居然就編譯通過了

 

22、error C2872: ‘ostream‘ : ambiguous symbol

改變了#include <iostream>的位置就好了

visual studio編譯錯誤集(轉)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.