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. Android编程小实验

    1.一个layout中存在相同id的控件会出现什么情况?   结论:编译和运行的时候都不会报错,不过使用findViewById()只会获取第一个该id的控件 来自为知笔记(Wiz)

  2. 我给女朋友讲编程html系列(3) --html中的超链接标签-a标签 和 框架frame与框架集frameset

    我们浏览网页的时候,当单击某段文字或图片时,就会打开一个新的网页,这里面就使用了超链接. 就比如下图是一个导航类网页,当你单击某个链接就会打开新的网页. 比如,我拿我的qq空间“金河访谈”举例,新建一 ...

  3. 【转】eclipse技巧1

    俗话说的好啊,“工于利启事,必先善其器”,如果说你的编程功底是一个枪法的话,那么强大的eclipse就是android战士们最好的武器. 这里,我们来总结eclipse的使用技巧,从而使我们的编程达到 ...

  4. NSIS中判断.net framework 是否安装

    在网上找了几个脚本,原理都是读取注册表进行判断,都可以用. 1.CheckDotNetFramework /* * Name: CheckDotNetFramework.nsh * Version: ...

  5. Windows下配置使用MemCached

    工具: memcached-1.2.6-win32-bin.zip     MemCached服务端程序(for win) Memcached Manager             win下的Mem ...

  6. 【BZOJ】【3676】【APIO2014】回文串

    回文自动机/Manacher+SA 这道题可以用Manacher找出本质不同的回文串(令max增大的所有回文串),然后再用SA跑出来有多少相同. 还有一种做法就是回文自动机(Orz Hzwer)的裸题 ...

  7. poi过滤操作后产生新的sheet

    public Sheet filterSheet(Sheet sheetToFilter){ if(sheetToFilter == null){ System.out.println("s ...

  8. Swift-2-基本操作符

    // Playground - noun: a place where people can play import UIKit // 基本运算符 // 运算符有3种: 单目运算符(如 -a),二目运 ...

  9. Python中的元类和__metaclass__

    1.什么是元类 元类让你来定义某些类是如何被创建的,从根本上说,赋予你如何创建类的控制权.可以把元类想成是一个类中类,或是一个类,它的实例是其它的类.当某个类调用type()函数时,你就会看到它到底是 ...

  10. UICollectionViewLayout

    http://blog.csdn.net/majiakun1/article/details/17204921