編譯出錯:fatal error C1001: INTERNAL COMPILER ERROR 和 鏈接出錯 unresolved external symbol _WinMain@16

1.fatal error C1001: INTERNAL COMPILER ERROR

最近在編譯一個VC6.0工程(開發環境:win2000+VS6.0+Sp6),在加入預編譯頭後出現了下面的編譯錯誤提示: c:/program files/microsoft visual studio/vc98/include/xlocnum(106) : fatal error C1001: INTERNAL COMPILER ERROR         (compiler file 'msc1.cpp', line 1794)          Please choose the Technical Support command on the Visual C++          Help menu, or open the Technical Support help file for more information Error executing cl.exe.

 工程中的每個cpp文件編譯都沒有問題(除了預編譯頭對應的cpp文件),很是奇怪,於是在網上找了一下,找到下面一種解決辦法:

VC6.0的一個編譯錯誤的解決

在window98下使用vc6.0時,如果預編譯頭文件(stdafx.h)中包含了模板類的頭文件,比如atl的頭文件時,編譯器會報錯: fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 1786)

造成這種問題的原因是編譯器分配的內存超過了限制。 解決的辦法有三種: 1.給編譯器增大內存限制。在project(工程)->setting(設置)->c/c++的project option(工程選項)中,添加/Zm#nn選項,#nn是一個數字,取值最大爲2000。默認爲100。但是這種方法好像沒有什麼用處。 2.將模板類頭文件從stdafx.h中移出; 3.不使用預編譯頭文件。project->setting->c/c++,選擇所有的.cpp文件,都使用“不使用預編譯頭文件“的選項。缺點是編譯的時候很慢。

http://www.ieasy.org/yuzuo/archives/2005_07.html

還有一個英文的:

I see that while compiling ITEL.CPP it is trying and failing to open Debug/IODIARY.PCH. I also see that there is no IODIARY.CPP. Exactly how is IODIARY.PCH supposed to be created? Turn off precompiled headers for all files in the project, and rebuild. If the build still fails, then... uh-oh.. Modify the project to use the default STDAFX.CPP/STDAFX.H method of using PCH. Then, add an empty file STDAFX.H and an empty file STDAFX.CPP to the project. Then, for each .CPP file, add as the first line #include "stdafx.h" . Then compile. This should work. If it does not... uh-oh. In order for pre-compiled headers to work properly each .CPP must have as its first #include statement the name of the one .H (such as STDAFX.H) that includes all the "actual" .H's (windows.h, stdio.h, etc.) that should be included by ALL .CPPs. That is the important part. You don't usually want EVERYsingle .H that is included in ANY .CPP in the project to be in STDAFX.H -- you do normally want windows.h, because it is the big one that can include a lot and is usually included in every .CPP. Putting just windows.h in stdafx.h (and removing it from all the .CPPs) can speed up the build tremendously. http://www.codecomments.com/archive307-2005-3-421145.html

在MSDN中搜索到這種錯誤相關主題:

*http://lab.msdn.microsoft.com/productfeedback/SearchResults.aspx?text=fatal+error+C1001%3a+INTERNAL+COMPILER+ERROR&stype=1&fields=1&type=0&witId=0&pId=0&category=0&os=0&oslang=0&status=0&msstatus=0&resolution=0&chgdays=&validation=0&votes=&voterating=0&workarounds=False&attachments=False

*http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/c1001.asp

後來把預編譯去掉後,Build終於通過了運行了,可這也太慢了,鬱悶中……

還不知有沒更好的解決辦法??同樣的工程放在VC++.net2003中卻編譯順利通過,運行正常.!!!!

 

2.unresolved external symbol _WinMain@16

下載源代碼後鏈接出了問題,提示如上所示

在網上找到了解決方法

一,問題描述error LNK2001: unresolved external symbol _WinMainᤐdebug/main.exe:fatal error LNK 1120:1 unresolved externals error executing link.exe;

二,產生這個問題可能的原因

1, 你用vc建了一個控制檯程序,它的入口函數應該是main, 而你使用了WinMain.

2.  你用vc打開了一個.c/.cpp 文件,然後直接編譯這個文件,這個文件中使用了WinMian而不是main作爲入口函數。vc這時的默認設置是針對控制檯程序的。

三, 解決方法

1.進入project->setting->c/c++, 在category中選擇preprocessor,在processor definitions中刪除_WINDOWS, 添加_CONSOLE

2.進入project->setting->Link, 在Project options中將/subsystem:windows.改爲/subsystem:console

3.保存設置,Rebuild All. 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章