vc++ 6.0中使用CString::AllocSysString时链接错误

Link errors while using CString::AllocSysString in VC++ 6.0

本文关键字:AllocSysString 链接 错误 CString vc++      更新时间:2023-10-16

添加了以下代码

BSTR pbstrBuffer;
pbstrBuffer = buff.AllocSysString();

在构建项目时,我得到了以下错误:

Linking...
  Creating library pcciortl.lib and object pcciortl.exp .obj : error LNK2001: unresolved external symbol "public: unsigned short  * __thiscall CString::AllocSysString(void)const " (?AllocSysString@CString@@QBEPAGXZ)

c:pct3/pcciortl.dll: fatal error LNK1120: 1个未解析的外部文件执行link.exe出错。

其他CString方法似乎没问题。我该怎么办?

找到手动包含mfco42d.lib的解决方案,然后找出真正的解决方案,在项目中包含一个MFC包含文件

#include <afxole.h>         // MFC OLE classes
#include <afxdisp.h>        // MFC OLE automation classes

它的作用是在Visual c++ 6.0中包含库mfco42d.lib