当我定义了fstream对象并调用其任意方法,编译(compile)通过,连接(link)时为什么必须main()函数定义,加上空的main函数体后就能通过?请高手指点
解决方案 »
- Listbox 默认第一项画一次焦点矩形(DrawFocusRect)//这个怎么改呀?
- 窗口句柄与实例句柄的区别!!
- 为什么我在不同机器上取得的CPUID都一样呢?
- 关于CSliderCtrl控件的问题
- ★ 如何作一个控件可以嵌入到IE中使IE可以打开一种自定义格式的文件。
- VC里怎么使用花指令?
- Windows media format 的版本信息怎么得到亚
- 请问如何实现在浏览中选定一个文件夹返回
- 有西安的朋友吗?,帮帮忙,有分的!!!!!
- SOS!紧急求救!有没有通过文件名就能得到当前和该文件相关联的可执行文件的SDK函数
- 树视图问题
- hr =pDoc.CreateInstance(__uuidof(MSXML2::IXMLDOMDocument2));??
纯C++开发ActiveX控件????
做什么,海的研究的那么底层?
fprintf
等函数应该不会出现这种问题
Linking...
Creating library Debug/dsoframer.lib and object Debug/dsoframer.exp
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/dsoframer.ocx : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
请给予更多指点
LIBCMT.LIB
MSVCRT.LIB可能没加
--------------------------------------------------------------------------------
The information in this article applies to: Microsoft Visual Studio 6.0
Microsoft Visual C++, 32-bit Professional Edition 6.0
Microsoft Visual Basic Enterprise Edition for Windows 6.0--------------------------------------------------------------------------------
Symptoms
When you build a project of one of these types Win32 console application project
Active Template Library (ATL) DLL/EXE project with release configuration
A project with main as custom entry point
you may get the following error message from linker:
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Cause
A Win32 console application requires the main function as the entry point. Linker returns this error message when it cannot find the main function in any of the files attached to the project.If your project is an ATL project, the release configurations for ATL projects define _ATL_MIN_CRT, which excludes CRT (C runtime) startup code from your .exe or .dll file. Linker gives this error message when you have _ATL_MIN_CRT defined and you are using the CRT functions that need CRT startup code.If the project is not one of the types listed in the "Symptoms" section of this article, but you are still getting the error, you might have main selected as an entry point symbol for the project in linker settings but have not provided a main function in the files added to the project. ResolutionIf you have created a Win32 console application instead of a Win32 application by mistake, there are two ways to fix this problem:
From the Project menu, choose Settings, click the C/C++ tab, and change preprocessor definitions from WIN32, _DEBUG, _CONSOLE, and _MBCS to WIN32, _DEBUG, and _WINDOWS. Next, click the Link tab, and under Project Options, change /subsystem:console to /subsystem:windows. -or-
Create a new project and select Win32 Application instead of Win32 Console Application. Add the files to that project.
If you have created a Win32 console application and forgot to provide a main function, write a main function in one of the source files added to the project.
If you have selected main as the custom entry point by mistake, from the Project menu, choose Settings and click the Linker tab. Select output as the category and remove main from the entry-point symbol text box.
If your project is an ATL project, there are two ways to fix the problem:
Remove _ATL_MIN_CRT from the list of preprocessor definitions to allow CRT startup code to be included: From the Build menu, choose Settings. Hold down the CTRL key while selecting all of the release configurations. On the C/C++ tab, choose the General category, and then remove _ATL_MIN_CRT from the preprocessor definitions edit box. -or-
If possible, remove calls to CRT functions that require CRT startup code and use their Win32 equivalents. For example, use lstrcmp instead of strcmp. Known functions that require CRT startup code include the string and floating point functions. Status
This behavior is by design. More Information
The following are the entry points for the various types of projects: main: console project
WinMain: Win32 project
DllMain: Win32 DLL project (if you link with the CRT libraries, you don't have to specify one because it adds a default DllMain)
The LNK2001 error specifies the symbol that causes the error. It means that the linker could not find the symbol in your project and the libraries that your project uses. Ensure that the symbol is present in a source file in your project. Otherwise, link to the appropriate static library, import library, or .obj file.AppWizard-generated ATL projects have this _ATL_MIN_CRT defined for release configurations. ATL is aimed at minimizing the image size and the reliance on run-time .dll files. It provides alternative implementations for common CRT APIs that would otherwise require the CRT startup code. The use of these APIs is controlled by the _ATL_MIN_CRT macro. If you are using _ATL_MIN_CRT, this does not mean that you cannot use the CRT routines. However, if you use the routines that require the CRT startup code, then you will get a linker error that _main is unresolved. Providing your own implementation of _main does not solve this problem. References
For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base: Q138400 Troubleshooting LNK2001 or L2029 Unresolved External Error
Q125750 PRB: Error LNK2001: '_WinMain@16': Unresolved External Symbol
Q131204 PRB: Wrong Project Selection Causes LNK2001 on _WinMain@16
Q166480 INFO: Active Template Library (ATL) Frequently Asked Questions
MSDN Online Library, Microsoft Visual C++ for Beginners
http://msdn.microsoft.com/library/techart/vc4begin.htmAdditional query words: LNK2001 Keywords: kbVC kbVS kbVS600 _IK
Issue Type: kbprb
Technology: kbVCsearch kbVSsearch kbVBSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB600Search kbVB600 kbVC600 kbVC32bitSearch kbVS600 kbVS600Search --------------------------------------------------------------------------------Send feedback to Microsoft© 2002-2003 Microsoft Corporation. All rights reserved.