Error 2 error LNK2019: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)" (?ConvertBSTRToString@_com_util@@YGPADPA_W@Z) referenced in function "public: char const * __thiscall _bstr_t::Data_t::GetString(void)const " (?GetString@Data_t@_bstr_t@@QBEPBDXZ) main.obj CPUTest

I met this error when programming a WMI C++ query application.

Research:
MSDN
Says :When calling a function in a static library or DLL that takes a
wchar_t type (note that BSTR and LPWSTR resolve to wchar_t*), you may
get an LNK2001 unresolved external symbol error.This error is caused by
the /Zc:wchar_t compiler option, which is set to on by default in new
MFC projects. This option causes the compiler to treat wchar_t as a
native type. Before Visual C++ .NET, wchar_t was treated as an unsigned
short.If the main project and library do not use the same setting for
/Zc:wchar_t, this will cause a mismatch of function signatures. To avoid
this problem, rebuild the library with the /Zc:wchar_t compiler option,
or turn it off in the main project using the Treat wchar_t as Built-in
Type setting on the Language property page in the Property Pages dialog
box.

Solution:
Add this:
#ifdef _DEBUG
# pragma comment(lib, "comsuppwd.lib")
#else
# pragma comment(lib, "comsuppw.lib")
#endif
# pragma comment(lib, "wbemuuid.lib")

Reference:
ConvertStringToBSTR
http://msdn.microsoft.com/en-us/library/t58y75c0.aspx

Posted by

vrbear

at

16:29

Labels:
SDK,
WMI

 
http://vrbear.blogspot.jp/2008/09/error-lnk2019-unresolved-external.html

Error LNK2019: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)"的更多相关文章

  1. 链接报error LNK2019: unresolved external symbol错误,解决

    http://blog.163.com/aiding_001/blog/static/22908192011102224344450/ 某次编写一个COM组件,接口定义好之后,增加了ZRX代码后编译链 ...

  2. C++ win32 dll 引用外部CLR,加载托管程序集异常-Error 10 error LNK2019: unresolved external symbol _CLRCreateInstancet

    异常: Error 10 error LNK2019: unresolved external symbol _CLRCreateInstance@12 referenced in function ...

  3. error LNK2019:unresolved external symbol

    error LNK2019:unresolved external symbol 这个错误是指程序不认识函数.具体的说就是.h文件中定义并没有实现,这就是库出现了问题. 遇到这个问题,第一步就要看是哪 ...

  4. c++模板使用出错情况error LNK2019: unresolved external symbol "public: float __thiscall Compare<float>::min(void)" (?min@?$Compare@M@@QAEMXZ) referenced in function _main

    将类模板在头文件中定义,类的成员函数在头文件中声明,头文件中只留下接口,函数的实现在另一个.cpp文件中,这样编译出来错误error LNK2019: unresolved external symb ...

  5. FreeType的项目总是报error LNK2019: unresolved external symbol __imp错误

    用vs2013建立了一个c++的项目,然后在根目录放置了freetype.lib,将GitHub上面的include文件夹拷贝到本机,并且在VS中设置了额外包含目录指向这个inluce文件夹,然后将f ...

  6. C++ Error: error LNK2019: unresolved external symbol

    在某工程中新添加了文件x.cu与x.hpp,实现了一些功能,最后编译整个工程的时候就出现了这个问题: error LNK2019: unresolved external symbol 这是链接错误, ...

  7. Error LNK2019:Unresolved External Symbol 的解决方案

    当头文件中声明了一个函数,但是在相应的源文件中却没有对该函数进行定义,则会出现为“解决的外部符号”(unresolved external symbol )错误.另外,当一个函数调用了外部的一个库文件 ...

  8. VS2015 MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4

    今天在VS2015中用编译好的QT5静态库打包软件,配置好QT的静态环境后, 发现报MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved ...

  9. error LNK2019 : unresolved external symbol Zbar配置问题

    原文链接:https://blog.csdn.net/MengchiCMC/article/details/77871714 出现error LNK2019 : unresolved external ...

随机推荐

  1. js节点解析

    在JS中,每一个节点都有一个nodeType 属性,用于表明节点的类型.节点类型由在Node 类型中定义的下列12个数值常量来表示,任何节点类型必居其一: Node.ELEMENT_NODE(1); ...

  2. js—对象

    一.创建对象 var car = new Object(); var car = {}; 二.属性和方法 var car = { color : "red", run : func ...

  3. 最小二乘法(least squares method)

    一.背景 号到北大去听hulu的讲座<推荐系统和计算广告在视频行业应用>,想到能见到传说中的项亮大神,特地拿了本<推荐系统实践>求签名.讲座开始,主讲人先问了下哪些同学有机器学 ...

  4. 如何做一个脚本自动打开IE浏览器

    打开记事本,输入start iexplore "http://www.baidu.com"这个是打开百度,如果只要打开IE就输入start iexplore然后另存为--保存类型改 ...

  5. 网页数据采集 - 系列之Flash数据采集

    经常看到一些朋友在讨论如何采集flash中的数据,讨论来讨论区,结论就是:flash不能采集,其实也不总是这样.本篇就跟大家分享如何采集flash中的数据. 在开始之前,先说明一下:一般来说flash ...

  6. C#基础——三元表达式

    采用三元操作符对?:对表达式进行运算,这种操作符比较特别,因为它有三个操作对象,但它确实属于操作符的一种,它最终也会生成一个值.其表达式采取下述形式: boolean-exp ? value0 : v ...

  7. fwrite ,fprintf的作用与区别

    1.概念和作用 fwrite是C语言函数,指向文件写入一个数据块,写入的是 fprintf是C/C++中的一个格式化写-库函数,其作用是格式输出到一个流/文件中:原型是int fprintf( FIL ...

  8. windows下配置nodejs+npm

    windows下安装nodejs是比较方便的 (v0.6.0之后,支持windows native),进入官网http://nodejs.org/  点击install即可安装.下载完成后一路next ...

  9. 堆(heap)和栈(stack)的区别

    转: 一.预备知识―程序的内存分配 一个由c/C++编译的程序占用的内存分为以下几个部分 1.栈区(stack)― 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等.其操作方式类似于数据结构中 ...

  10. 4-Highcharts曲线图之时间轴折线图

    鼠标按住左键 左右移动可以试试<!DOCTYPE> <html lang='en'> <head> <title>4-Highcharts曲线图之时间轴 ...