Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Link problem with ConvertStringToBSTR

445 views
Skip to first unread message

David JD Bell

unread,
Aug 28, 2002, 2:48:52 AM8/28/02
to
This piece of code in an ATL CComObject implementation...

...
#include <comutil.h>
...
struct _finddata_t c_file;
...
BSTR tFName = _com_util::ConvertStringToBSTR((const char*)c_file.name);
...

compiles OK, but gives the link error

BCiTool_DBS error LNK2019: unresolved external symbol "unsigned short *
__stdcall _com_util::ConvertStringToBSTR(char const *)"
(?ConvertStringToBSTR@_com_util@@YGPAGPBD@Z) referenced in function "public:
long __thiscall CBCiTool_DB::FinalConstruct(void)"
(?FinalConstruct@CBCiTool_DB@@QAEJXZ)


What I don't understand is why does the linker think BSTR tFName is an
unsigned short* ? Or should I use another function?

Thanks to anyone who can help.

David Bell


Jay Nabonne

unread,
Aug 28, 2002, 12:14:09 PM8/28/02
to

"David JD Bell" <davi...@hotmail.com> wrote in message
news:O7SCm6lTCHA.1900@tkmsftngp09...

> This piece of code in an ATL CComObject implementation...
>
> ...
> #include <comutil.h>
> ...
> struct _finddata_t c_file;
> ...
> BSTR tFName = _com_util::ConvertStringToBSTR((const char*)c_file.name);
> ...
>
> compiles OK, but gives the link error
>
> BCiTool_DBS error LNK2019: unresolved external symbol "unsigned short *
> __stdcall _com_util::ConvertStringToBSTR(char const *)"
> (?ConvertStringToBSTR@_com_util@@YGPAGPBD@Z) referenced in function
"public:
> long __thiscall CBCiTool_DB::FinalConstruct(void)"
> (?FinalConstruct@CBCiTool_DB@@QAEJXZ)
>

Does this apply?

http://support.microsoft.com/support/kb/articles/Q168/0/03.ASP

>
> What I don't understand is why does the linker think BSTR tFName is an
> unsigned short* ?

Platform SDK docs for BSTR gives the typedef as:

<quote>
typedef OLECHAR FAR* BSTR;
</quote>

OLECHAR is unsigned short, so...

> Or should I use another function?
>
> Thanks to anyone who can help.
>

Jay


David JD Bell

unread,
Aug 28, 2002, 6:26:52 PM8/28/02
to
No, this is with an unmanaged VC.NET project, and I am using __cdecl
calling anyway. Any other reasons? It also does the same thing with
ConvertBSTRToString.

Thanks

David Bell


David JD Bell

unread,
Aug 31, 2002, 6:39:04 PM8/31/02
to
Fixed it. I had

#include <comutil.h>

but also needed

#pragma comment(lib, "comsupp.lib")

Hope this isn't out of date... this NG seems to have died on my server.

David Bell

"Jay Nabonne" <j...@rightagain.com> wrote in message
news:#0ySO3qTCHA.1632@tkmsftngp11...

0 new messages