undefined reference to CException....

mm36995225 2013-08-02 10:43:44
一个程序模块,五个文件夹。base、param、proc编译都正确,而且生成的库放在了lib。编译app下的文件报错。错误是proc文件夹下的DbInterface.cpp undefined reference to CException::CException(char*,int,char const*,...). CException.cpp在param文件夹下。DbInterface.h已经包含了CException.h。是哪里问题?如何解决?
...全文
198 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
lm_whales 2013-08-04
  • 打赏
  • 举报
回复
建议贴出头文件.
lm_whales 2013-08-04
  • 打赏
  • 举报
回复
另外漏写分号,右括号,也会有类型未定义错误.
lm_whales 2013-08-04
  • 打赏
  • 举报
回复
CException?? 别告诉我,你用的是Vc ,并且还用了MFC; MFC类库就有CException,你又定义一个,会产生命名冲突,编译器当然不给你用CException 了. 名字冲突,CException有歧义,所以就是未定义的. 其他类库,编译器不知有没有,叫CException的类,不能确定,是什么问题. 当然,如果出现类的循环引用(两个类的头文件互相包含),也会出现,类型未定义错误.
todd_leftcode 2013-08-04
  • 打赏
  • 举报
回复
理论上像上CException.cpp不在你的那几个lib中, 看看有没有把它包含在工程里或Makefile里
赵4老师 2013-08-02
  • 打赏
  • 举报
回复
偶遇到类似问题都是用 “每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。” 的方法解决的。
zhctj159 2013-08-02
  • 打赏
  • 举报
回复
你给的信息少、、有图有真相,,,
max_min_ 2013-08-02
  • 打赏
  • 举报
回复
引用 5 楼 mm36995225 的回复:
感觉应该不是代码的问题。Makefile?哎。不知道。请高手指导

注意makefile里的库的调用顺序,如果你定义了话,
估计就是顺序问题了
赵4老师 2013-08-02
  • 打赏
  • 举报
回复
VC6: 工程、设置、C/C++、分类:Preprocessor、附加包含路径:填写附加头文件所在目录 逗号间隔多项 工程、设置、Link、分类:Input、附加库路径:填写附加依赖库所在目录 分号间隔多项 工程、设置、Link、分类:Input、对象/库模块:填写附加依赖库的名字.lib 空格间隔多项 VS20xx: 项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项 项目、属性、链接器、常规、附加库目录:填写附加依赖库所在目录 分号间隔多项 项目、属性、链接器、输入、附加依赖项:填写附加依赖库的名字.lib 空格或分号间隔多项
zhctj159 2013-08-02
  • 打赏
  • 举报
回复
链接的时候是没有链接CException模块吗?你准备用的是放在lib下的CException库文件还是proc下的CException.o文件?,,如果没有指定使用库或者库文件的路径不对,而又没有在链接的命令行指定CException.o就会出现你的错误。
zcm_xh2008 2013-08-02
  • 打赏
  • 举报
回复
检查一下头文件里面这个构造函数的参数是否和这个实现里面的参数一致。。。如果一致,我就不知道是怎么回事了。。。坐等高手了。。。小生是学得不久的菜鸟。。。
引用 7 楼 mm36995225 的回复:
[quote=引用 6 楼 zcm_xh2008 的回复:] 应该是你这个函数只有声明和调用,而没有实现。。。你看看呢。。。
实现了啊。CException.cpp里面就是函数的实现呀。 #include "CException.h" CException::CException() {} CException::~CException() {} CException::CException( char * errstr) { m_msg.push_back(CExceptionMsg(0,"__FILE__",errstr)); } CException::CException(char * filename, int linenum , const char * format ,...) { char *ls_str = new char[1024 * 10]; va_list pvar; va_start (pvar, format); vsprintf(ls_str,format,pvar); va_end(pvar); CExceptionMsg e(linenum,filename,ls_str); m_msg.push_back(e); delete[] ls_str; } void CException::toString() { vector<CExceptionMsg>::iterator it; for ( it = m_msg.begin(); it != m_msg.end(); it++) printf("File[%12s:%4d] Msg[ %s ]\n",it->m_filename,it->m_linenum,it->m_msg); } void CException::Push(CExceptionMsg msg) { m_msg.push_back(msg); } char* CException::GetString() { vector<CExceptionMsg>::iterator it; char *pstr = new char[1024]; int curpos = 0; int leftsize = sizeof(m_errstr) -1; int length = 0; for ( it = m_msg.begin(); it != m_msg.end(); it++) { sprintf(pstr,"File[%12s:%4d] Msg[ %s ]\n",it->m_filename,it->m_linenum,it->m_msg); length = strlen(pstr); leftsize -= length; if (leftsize < 0) break; strcpy(&m_errstr[curpos], pstr); curpos += length; } delete [] pstr;// return m_errstr; } CExceptionMsg::CExceptionMsg(char * filename, int linenum , char * format, ...) { strcpy(m_filename,filename); m_linenum = linenum; char *msg = new char[1024*2]; va_list pvar; va_start (pvar,format); vsprintf(msg,format,pvar); va_end (pvar); strncpy(m_msg,msg,sizeof(m_msg)-20); if (strlen(msg) > sizeof(m_msg)-20) { strcat(m_msg,"[[msg超长]]"); } delete [] msg; }[/quote]
mm36995225 2013-08-02
  • 打赏
  • 举报
回复
引用 6 楼 zcm_xh2008 的回复:
应该是你这个函数只有声明和调用,而没有实现。。。你看看呢。。。
实现了啊。CException.cpp里面就是函数的实现呀。 #include "CException.h" CException::CException() {} CException::~CException() {} CException::CException( char * errstr) { m_msg.push_back(CExceptionMsg(0,"__FILE__",errstr)); } CException::CException(char * filename, int linenum , const char * format ,...) { char *ls_str = new char[1024 * 10]; va_list pvar; va_start (pvar, format); vsprintf(ls_str,format,pvar); va_end(pvar); CExceptionMsg e(linenum,filename,ls_str); m_msg.push_back(e); delete[] ls_str; } void CException::toString() { vector<CExceptionMsg>::iterator it; for ( it = m_msg.begin(); it != m_msg.end(); it++) printf("File[%12s:%4d] Msg[ %s ]\n",it->m_filename,it->m_linenum,it->m_msg); } void CException::Push(CExceptionMsg msg) { m_msg.push_back(msg); } char* CException::GetString() { vector<CExceptionMsg>::iterator it; char *pstr = new char[1024]; int curpos = 0; int leftsize = sizeof(m_errstr) -1; int length = 0; for ( it = m_msg.begin(); it != m_msg.end(); it++) { sprintf(pstr,"File[%12s:%4d] Msg[ %s ]\n",it->m_filename,it->m_linenum,it->m_msg); length = strlen(pstr); leftsize -= length; if (leftsize < 0) break; strcpy(&m_errstr[curpos], pstr); curpos += length; } delete [] pstr;// return m_errstr; } CExceptionMsg::CExceptionMsg(char * filename, int linenum , char * format, ...) { strcpy(m_filename,filename); m_linenum = linenum; char *msg = new char[1024*2]; va_list pvar; va_start (pvar,format); vsprintf(msg,format,pvar); va_end (pvar); strncpy(m_msg,msg,sizeof(m_msg)-20); if (strlen(msg) > sizeof(m_msg)-20) { strcat(m_msg,"[[msg超长]]"); } delete [] msg; }
zcm_xh2008 2013-08-02
  • 打赏
  • 举报
回复
应该是你这个函数只有声明和调用,而没有实现。。。你看看呢。。。
mm36995225 2013-08-02
  • 打赏
  • 举报
回复
感觉应该不是代码的问题。Makefile?哎。不知道。请高手指导
mm36995225 2013-08-02
  • 打赏
  • 举报
回复
引用 2 楼 zhao4zhong1 的回复:
偶遇到类似问题都是用 “每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。” 的方法解决的。
恩,你的方法可以尝试。但是文件太多。哎。试试吧。谢谢
mm36995225 2013-08-02
  • 打赏
  • 举报
回复
引用 1 楼 zhctj159 的回复:
你给的信息少、、有图有真相,,,
就是这个问题。
MFC类目录及头文件 类 描述 头文件 CAnimateCtrl 自动化通用控件 afxcmn.h CArchive afx.h CArchiveException afx.h CArray afxtempl.h CAsyncMonikerFile 在ActiveX控件中提供对异步标记的支持 afxole.h CAsyncScoket 封装Windows Sockets API,参看CSocket afxsock.h CBitmap afxwin.h CBitmapButton afxext.h CBrush afxwin.h CButton 按钮控件对象 afxwin.h CByteArray afxcoll.h CCachedDataPathProperty 允许一个ActiveX控件异步传输属性数据和缓冲内存中的数据,参考CDataPathProperty afxctl.h CCheckListBox afxwin.h CClientDC afxwin.h CCmdTarget 所有能够接收和响应消息的对象的基类 afxwin.h CCmdUI afxwin.h CColorDialog 颜色选择的通用对话框,提供为显示系统定义的颜色列表 afxdlgs.h CComboBox 组合框对象 afxwin.h CComboBoxEx CComboBox类的派生类,用于支持在组合框控件中的图像列表 afxcmn.h CCommandLineInfo afxwin.h CCommonDialog afxdlgs.h CConnectionPoint afxdisp.h CControlBar afxext.h CCreateContext afxext.h CCriticalSection afxmt.h CCtrlView afxwin.h CDaoDatabase afxdao.h CDaoException afxdao.h CDaoFieldExchange afxdao.h CDaoQueryDef afxdao.h CDaoRecordset 代表选自数据源的记录集。CDaoRecordset对象可用于三种格式:表类型记录集,动态集类型记录集和快照类型记录集 afxdao.h CDaoRecordView 提供表单视图,以在控件中显示数据库记录。表单视图是CDaoRecordset对象的一部分。参考CFormView和CRecordView afxdao.h CDaoTableDef afxdao.h CDaoWorkspace afxdao.h CDatabase afxdb.h CDataExchange afxwin.h CDataPathProperty 实现一个ActiveX控件属性,它能够异步加载其数据。这个类允许ActiveX控件在后台下载属性数据时被激活 afxctl.h CDateTimeCtrl 封装新的日期/时间选取器控件 afxdtctl.h CDBException afxdb.h CDBVariant afxdb.h CDC afxwin.h CDialog 用于包含控件窗口的对话框对象 afxwin.h CDialogBar afxext.h CDocItem afxole.h CDockState afxadv.h CDocObjectServer afxdocob.h CDocObjectServerItem afxdocob.h CDocTemplate afxwin.h CDocument 用于管理程序的数据的类 afxwin.h CDragListBox Windows列表框,允许用户把其中的项拖放到不同的位置 afxcmn.h CDumpContext afx.h CDWordArray afxcoll.h CEdit 用于文本输入的子窗口控件 afxwin.h CEditView 提供Windows编缉控件的功能。因为CEditView派生于Cedit,该对象可同文件和文件模板一同使用 afxext.h CEvent afxmt.h CException afx.h CFieldExchange afxdb.h CFile afx.h CFileDialog 通用文件对话框,提供Open和Save As对话框中的功能 afxdlgs.h CFileException afx.h CFileFind afx.h CFindReplaceDialog afxdlgs.h CFont afxwin.h CFontDialog 通用字体对话框,用于显示当前已装入系统的字体列表 afxdlgs.h CFontHolder afxctl.h CFormView 包含对话框控件的窗口 afxext.h CFrameWnd SDI(单窗口界面)框架窗口 afxwin.h CFtpConnection afxinet.h CFtpFileFind afxinet.h CGdiObject afxwin.h CGopherConnection afxinet.h CGopherFile afxinet.h CGopherFileFind afxinet.h CGopherLocator afxinet.h CHeaderCtrl 标题通用控件 afxcmn.h CHotKeyCtrl 热键通用控件 afxcmn.h CHtmlStream afxisapi.h CHtmlView 实现Web Browser控件的视图类,能够访问当地或Web上的HTML文件。 afxhtml.h CHttpConnection afxinet.h CHttpFile afxinet.h CHttpFilter 创建并处理超文传输协议过滤器对象,该对象用于过滤用于HTTP请求的服务器通知 afxisapi.h CHttpFilterContext afxisapi.h CHttpServer Internet Server API(ISAPI)的包装类 afxisapi.h CHttpServerContext afxisapi.h CImageList afxcmn.h CInternetConnection afxinet.h CInternetException afxinet.h CInternetFile afxinet.h CInternetSession afxinet.h CIPAddressCtrl IP地址控件。类似于编缉框,该控件接收Internet 协议格式的地址 afxcmn.h CList afxtempl.h CListBox 列表框对象 afxwin.h CListCtrl 列表视通用控件 afxcmn.h ClistView 简化CListCtrl的使用,添加了对文件和视图的支持 afxcview.h CLongBinary afxdb_.h CMap afxtempl.h CMapPtrToPtr afxcoll.h CMapPtrToWord afxcoll.h CMapStringToOb afxcoll.h CMapStringToPtr afxcoll.h CMapStringToString afxcoll.h CMapWordToOb afxcoll.h CMapWordToPtr afxcoll.h CMDIChildWnd MDI(多文档界面)子框架窗口 afxwin.h CMDIFrameWnd afxwin.h CMemFile afx.h CMemoryException afx.h CMemoryState CMenu afxwin.h CMetaFileDC afxext.h CMiniFrameWnd 半高的框架窗口,主要用于浮动工具栏。一个小框架窗口没有最小化和最大化按钮,但其他都类似于正常的框架窗口 afxwin.h CMonikerFile afxole.h CMonthCalCtrl 月历控件,用于显示一个用户可选择日期的日历 afxdtctl.h CMultiDocTemplate afxwin.h CMultiLock afxmt.h CMutex afxmt.h CNotSupportedException afx.h CObArray afxcoll.h CObject afx.h CObList afxcoll.h COleBusyDialog afxodlgs.h COleChangeIconDialog afxodlgs.h COleChangeSourceDialog afxodlgs.h COleClientItem afxole.h COleCmdUI afxdocob.h COleControl afxctl.h COleControlModule afxctl.h COleConvertDialog afxodlgs.h COleCurrency afxdisp.h COleDataObject afxole.h COleDataSource afxole.h COleDateTime afxdisp.h COleDateTimeSpan afxdisp.h COleDBRecordView afxoledb.h COleDialog afxodlgs.h COleDispatchDriver afxdisp.h COleDispatchException afxdisp.h COleDocObjectItem afxole.h COleDocument 把一个文件看作为CDocItem对象的一个集合。包容器和服务器都需要这个结构,因为它们的文件必须能够包含OLE项 afxole.h COleDropSource afxole.h COleDropTarget afxole.h COleException afxdisp.h COleInsertDialog afxodlgs.h COleIPFrameWnd afxole.h COleLinkingDoc OLE包容器文件的基类,这些文件支持对它们所包含项的链接 afxole.h COleLinksDialog afxodlgs.h COleMessageFilter afxole.h COleObjectFactory afxdisp.h COlePasteSpecialDialog afxodlgs.h COlePropertiesDialog afxodlgs.h COlePropertyPage afxctl.h COleResizeBar afxole.h COleSafeArray afxdisp.h COleServerDoc OLE服务器文件的基类 afxole.h COleServerItem 为OLE项提供一个服务器界面 afxole.h COleStreamFile afxole.h COleTemplateServer afxdisp.h COleUpdateDialog afxodlgs.h COleVariant afxdisp.h CPageSetupDialog afxdlgs.h CPaintDC afxwin.h CPalette afxwin.h CPen afxwin.h CPictureHolder afxctl.h CPoint atltypes.h CPrintDialog 通用打印对话框,提供Print和Print Setup对话框中的功能 afxdlgs.h CPrintInfo CProgressCtrl 通用进程指示器控件 afxcmn.h CPropertyPage 代表属性表单中的一页 afxdlgs.h CPropertyPageEx CPropertySheet 属性表,也叫做多选项卡对话框。一个属性表由一个CPropertySheet对象和几个CPropertyPage对象组成 afxdlgs.h CPropertySheetEx CPropExchange afxctl.h CPtrArray afxcoll.h CPtrList afxcoll.h CReBar afxext.h CReBarCtrl afxcmn.h CRecentFileList afxadv.h CRecordset 用于访问数据库表或查询的类 afxdb.h CRecordView 包含对话框控件的窗口 afxdb.h CRect atltypes.h CRectTracker afxext.h CResourceException afxwin.h CRgn afxwin.h CRichEditCntrItem afxrich.h CRichEditCtrl 用户能够输入和编缉文本的窗口,提供字符和程序段格式,以及对嵌入OLE项的支持 afxcmn.h CRichEditDoc afxrich.h CRichEditView afxrich.h CRuntimeClass CScrollBar 滚动条对象 afxwin.h CScrollView 可滚动的窗口,派生于CView afxwin.h CSemaphore afxmt.h CSharedFile afxadv.h CSingleDocTemplate afxwin.h CSingleLock afxmt.h CSize atltypes.h CSliderCtrl 提供包含一个滑块和可选的刻度线的窗口 afxcmn.h CSocket Windows Socket API的包装类 afxsock.h CSocketFile afxsock.h CSpinButtonCtrl 提供箭头按钮,用户可单击它,以增加或减少某个控件中的一个值 afxcmn.h CSplitterWnd afxext.h CStatic 用于标识另一个控件或给用户提供消息的简单文本框 afxwin.h CStatusBar afxext.h CStatusBarCtrl 提供一个层次窗口,通常放于父窗口的底部,用于显示关于应用程序的状态信息 afxcmn.h CStdioFile afx.h CString afx.h CStringArray afxcoll.h CStringList afxcoll.h CSyncObject afxmt.h CTabCtrl 允许应用程序在一个窗口或对话框的同一区域显示多个页面 afxcmn.h CTime afx.h CTimeSpan afx.h CToolBar afxext.h CToolBarCtrl 工具栏通用控件 afxcmn.h CToolTipCtrl 提供工具提示控件的功能,它以一个小弹出窗口的样子显示,包含描述某个工具用途的一行文本 afxcmn.h CTreeCtrl 显示项的分层结构列表 afxcmn.h CTreeView 简化CTreeCtrl的用法 afxcview.h CTypedPtrArray afxtempl.h CTypedPtrList afxtempl.h CTypedPtrMap afxtempl.h CUIntArray afxcoll.h CUserException afxwin.h CView 用于显示程序数据的类 afxwin.h CWaitCursor afxwin.h CWinApp afxwin.h CWindowDC afxwin.h CWinThread 代表一个应用程序中的一个线程 afxwin.h CWnd afxwin.h CWordArray afxcoll.h ......

64,649

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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