debug程序正确,release时出现错误,在线等待高手帮忙解决
debug程序正确,release时出现如下错误:(SystemTray.h文件中我找不到下面出现的函数)
请帮忙解决,在线等待
SmsServer error LNK2005: "public: static class ATL::COleDateTime __stdcall ATL::COleDateTime::GetTickCount(void)" (?GetTickCount@COleDateTime@ATL@@SG?AV12@XZ) already defined in SystemTray.obj
SmsServer error LNK2005: "public: __thiscall ATL::COleDateTime::COleDateTime(void)" (??0COleDateTime@ATL@@QAE@XZ) already defined in SystemTray.obj
SmsServer error LNK2005: "public: __thiscall ATL::COleDateTime::COleDateTime(__int64)" (??0COleDateTime@ATL@@QAE@_J@Z) already defined in SystemTray.obj
SmsServer error LNK2005: "public: class ATL::COleDateTime & __thiscall ATL::COleDateTime::operator=(__int64 const &)" (??4COleDateTime@ATL@@QAEAAV01@AB_J@Z) already defined in SystemTray.obj
SmsServer error LNK2005: "public: class ATL::COleDateTimeSpan __thiscall ATL::COleDateTime::operator-(class ATL::COleDateTime const &)const " (??GCOleDateTime@ATL@@QBE?AVCOleDateTimeSpan@1@ABV01@@Z) already defined in SystemTray.obj
SmsServer error LNK2005: "protected: static double __stdcall ATL::COleDateTime::DoubleFromDate(double)" (?DoubleFromDate@COleDateTime@ATL@@KGNN@Z) already defined in SystemTray.obj
问题点数:40、回复次数:14Top
1 楼dirdirdir3(风)回复于 2005-08-04 11:47:19 得分 0
对比一下在project->setting->link里面debug版本和release版本有什么不同。Top
2 楼happyparrot(快乐鹦鹉)回复于 2005-08-04 11:52:32 得分 0
对,看看Release和debug的环境设置是否相同Top
3 楼zengqianghua1120(强中华)回复于 2005-08-04 12:34:11 得分 0
在link里面设置是一样的,不知还有什么情况会引起这种错误?Top
4 楼zengqianghua1120(强中华)回复于 2005-08-04 12:36:04 得分 0
开发环境是在vc.net上,请帮忙解决!Top
5 楼happyparrot(快乐鹦鹉)回复于 2005-08-04 12:51:43 得分 0
SystemTray.h包含什么头文件了么?
程序中有没有预编译语句阿?比如判断是debug版本才做什么事情,或者是判断Release版本才做什么事情Top
6 楼surstar(我要写个操作系统出来……)回复于 2005-08-04 12:52:36 得分 0
加LINK 选项
/verbose:libTop
7 楼zengqianghua1120(强中华)回复于 2005-08-04 14:50:11 得分 0
仔细检查了代码发现由以下代码引起,将其注释就不出现错误了,并发现一个现象将鼠标放到类COleDateTime上居然提示为:class ATL::COleDateTime,怎么是ATL的类了?
COleDateTime m_StartTime;
m_StartTime = COleDateTime::GetCurrentTime();
COleDateTime CurrentTime = COleDateTime::GetCurrentTime();
COleDateTimeSpan period = CurrentTime - m_StartTime;
if (m_nAnimationPeriod > 0 && m_nAnimationPeriod < period.GetTotalSeconds())
{
StopAnimation();
return;
}
请各位多多指点,我该如何处理?Top
8 楼zengqianghua1120(强中华)回复于 2005-08-04 14:53:52 得分 0
SystemTray.h包含头文件为:#include <afxtempl.h>
工程中并无debug版本和release版本判断,他们之间在工程中应该一致的
加LINK选项“/verbose:lib”问题依旧,主要是我上面说的原因,请帮忙指点!
Top
9 楼zengqianghua1120(强中华)回复于 2005-08-04 15:12:14 得分 0
请高手帮忙解决,着急等待!Top
10 楼fisker0303(天塌了,地陷了,小花狗不见了.)回复于 2005-08-04 17:32:39 得分 0
看看变量的初始化。Top
11 楼zengqianghua1120(强中华)回复于 2005-08-09 11:32:40 得分 0
初始化变量有什么特别要注意的吗?Top
12 楼yzkzero()回复于 2005-08-09 18:49:32 得分 0
release没有包含必要的lib文件,在选项里添加,参照debug设置Top
13 楼yzkzero()回复于 2005-08-09 18:50:48 得分 0
不好意思,link里选项一样就不知道了Top
14 楼hasia(hasia)回复于 2005-08-15 15:10:00 得分 0
是不是变量重复定义了
SystemTray.h,SystemTray.c都有了,才导致的这些问题,因为提示说函数已经存在了
在SystemTray.h中用#ifndef...#define...#endif试试
另外,COleDataTime是没有基类的,因此用的是ATL,需要头文件ATLComTime.h
此外在MFC中用ATL,还需要做一些修改的
这是msdn的话
Adding ATL Support to Your MFC ProjectSee Also
Adding a Class | Working with Classes | Adding a Member Function | Adding a Member Variable | Overriding a Virtual Function | Adding a Message Handler | Navigating the Class Structure
If you have already created an MFC-based application, then you can add support for the Active Template Library (ATL) easily by running the Add ATL Support to MFC Project Wizard.
Note This support applies only to simple COM objects added to an MFC executable or DLL project. You can add other COM objects (including ActiveX controls) to MFC projects, but the objects might not operate as expected.
To add ATL support to your MFC project
1。In Solution Explorer, right-click the project to which you want to add ATL support.
2。On the shortcut menu, click Add, and then click Add Class.
3。Select the Add ATL Support to MFC Project icon.
Note This icon is located in the ATL folder in the Categories pane.
4。When prompted, click Yes to add ATL support.
Top




