使用_com_util::ConvertBSTRToString(BSTR)的奇怪问题(Release link报错)

iProgram 2004-01-01 02:06:37
新年哈,我用ATL Wizard生成一个project,增加一个ATL Object,再加入一个函数,函数中用到了ConvertBSTRToString:

#include <comutil.h>
#pragma comment(lib, "comsupp.lib")

STDMETHODIMP CMyClass::MyFunction(BSTR sData, long *len)
{
LPSTR lpszData = _com_util::ConvertBSTRToString(sData);
....
}
Debug编译没问题,但是无论Release MiniSize还是Release MiniDependence编译都会报告讨厌的LNK2001错误:
Linking...
Creating library ReleaseMinDependency/MyTest.lib and object ReleaseMinDependency/MyTest.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinDependency/MyTest.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

我把LPSTR lpszData = _com_util::ConvertBSTRToString(sData);注释掉就没问题。 我试过用Wizard生成一个最小的test程序都会这样,Debug没问题。
...全文
263 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
iProgram 2004-01-01
  • 打赏
  • 举报
回复
Thank you so much. It works like a charm:)
ross33123 2004-01-01
  • 打赏
  • 举报
回复
去掉 _ATL_MIN_CRT

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.

luohualiushui 2004-01-01
  • 打赏
  • 举报
回复
新年好

没用过_com_util类,这种情况下我用CComBSTR类转

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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