C++连接错误,搞不懂。各位帮忙看看。

allan 2000-09-04 10:23:00
Clib.h 中定义了struct CStash
Clib.cpp中
#include "CLib.h"
#include <iostream>
#include <cassert>
using namespace std;

其他源码省掉了,因为是书上的例程。

编译无错误,但link时,出错:
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

这个错误是什么意思呀?
多谢了。

苦恼
...全文
387 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
darkay 2001-01-20
  • 打赏
  • 举报
回复
一堆人在讨论什么东西啊,我不觉得一个来这里问问题的人连没有写main的错误都不知道的!其实问题不是在这里。我想你用的是VC,那么我可以告诉你VC 没有将所有的LIB都安装到硬盘中,它将一些不常用的与控制台相关的函数库留在CD中,看名字你也看得出来叫libcd.lib(是个很大的库),你只有将他们拷贝到硬盘的LIB目录中就行拉,或者在连接的时候将VC的CD放在光驱中。
hedayu 2001-01-18
  • 打赏
  • 举报
回复
没有主函数嘛。给他们分啊。
JungleBoy 2001-01-15
  • 打赏
  • 举报
回复
问题解决没有?给我分吧!
JungleBoy 2001-01-13
  • 打赏
  • 举报
回复
你的主程序叫什么?main || WinMain ?
多半是WinMain,但是Vc又给你生成了Console程序,如果是这样的话可以这样搞定:
Project --->
Setting --->
Link选项卡下面的文本框:
看没看到: /subsystem:console ?
如果看到就把console改成windows或者干脆把这句删掉,Linker会自己去找main WinMain如果找到前着他就连接成console程序,后者就是窗口程序。要是都找不到你的程序显然就有错了!
sun2000 2000-11-22
  • 打赏
  • 举报
回复
#include "windows.h"
xubin_sh 2000-11-21
  • 打赏
  • 举报
回复
在MSDN上有相关文档
Note for Release builds only When the ATL COM AppWizard generates the default project, it defines the macro _ATL_MIN_CRT. This macro is defined so that you don't bring the C Run-Time Library into your code if you don't need it. The polygon control needs the C Run-Time Library start-up code to initialize the floating-point functions. Therefore, you need to remove the _ATL_MIN_CRT macro if you want to build a Release version. To remove the macro, click Settings on the Project menu. In the Settings For: drop-down list, choose Multiple Configurations. In the Select project configuration(s) to modify dialog box that appears, click the check boxes for all four Release versions, then click OK. On the C/C++ tab, choose the General category, then remove _ATL_MIN_CRT from the Preprocessor definitions edit box.
简要说一下,就是ATL project预定义了_ATL_MIN_CRT,有了这宏就不包括C Runtime Library(CRT)了,然而你用了Stl,又用到了CRT,CRT在link到你程序的时候发现,你的程序里面没有main(),所以你只要把_ATL_MIN_CRT这个预定义删掉就可以了,删法我就不写了,上面e文里面有的。
killjapan05 2000-10-02
  • 打赏
  • 举报
回复
project->setting->link,把project options处通通删掉,在试试
hxl 2000-10-02
  • 打赏
  • 举报
回复
递归包含CLib.h了,检查其他包含CLib.h的文件!
boodweb 2000-10-01
  • 打赏
  • 举报
回复
估计你的程序编译类型有问题,比如是windows appilication 还是 consol appilication
或者有没有把MFC库连接进去......
U皮特U 2000-09-04
  • 打赏
  • 举报
回复
找不到main函数,这可是程序入口函数呀!
Kevin_qing 2000-09-04
  • 打赏
  • 举报
回复
你没有定义main函数,即程序的主函数。连接程序就找不到该程序的入口地址。
c 语言程序是从main函数开始运行的。

69,364

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧