error LNK2019 related to ConvertStringToBSTR

Hello,

I'm trying to do a build on an open source project www.quickfixengine.org and getting some errors.  The code is unmodified from when I downloaded it.  I just brought it into Visual C++ so this should work.

Here's the output:

1>------ Build started: Project: at, Configuration: Debug Win32 ------

1>Linking...

1>quickfix.lib(MSXML_DOMDocument.obj) : error LNK2019: unresolved external symbol "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)" ( ConvertStringToBSTR@_com_util@@YGPA_WPBD@Z) referenced in function "public: __thiscall _bstr_t::Data_t::Data_t(char const *)" ( 0Data_t@_bstr_t@@QAE@PBD@Z)

1>quickfix.lib(MSXML_DOMDocument.obj) : 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)

1>bin\debug\at.exe : fatal error LNK1120: 2 unresolved externals

1>Build log was saved at "file://c:\Documents and Settings\centurion.PAXNY\Desktop\quickfix-1.10.2_NEW\quickfix\Debug\BuildLog.htm"

1>at - 3 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========



Answer this question

error LNK2019 related to ConvertStringToBSTR

  • david999

    The author of the code thought it was related to me not having comsupp.lib or not linking it but the directory that contains it is included in my VC++ Directories under options.

  • Erik van Noorden

    Thanks a ton it worked for me .........Smile


  • mooresmm

    Hello,

    I am also seeing the same problem. I am building the program using Visual Studio 2005 PRO for x64.

    I have added the path to the comsupp.lib for x64 in the Directories under "options".

    It still returns the same linker error. Also, I have also added the path under Linker\Inputs but the error still occurs.

    Any other pointers

    Thanks,

    Sonia.


  • jonbon

    Hello,

    I met the problem and i try both solution to fix the issue :

    1. using comsuppwd.lib
    2. use /Zc:char_t- compiler setting

    Both solution are working correctly.

    I just want to precise some point :

    This issue appear after VS2005 SP1 installation.

    This issue appear an an old project create on VS6 migrate to VS2003 to VS2005 and finaly build on SP1.

    In my opinion It seems more relevant to use the second approach using /Zc:char_t compiler setting than the fist one. I interest in thinking about the best solution.

    Michel


  • Badmick

    In VS2005.

    Try to link "comsuppwd.lib" in debug AdditionalDependencies.
    Link "comsuppw.lib" in release AdditionalDependencies.

     

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


  • Tom Niwinski

    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.

  • alex2323

    I had the exact same problem, and I resolved it with these five code lines:

    // File lib da includere per la corretta compilazione e linkaggio del file

    #ifdef _DEBUG

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

    #else

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

    #endif

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

    I think that this trick could be useful for many developers... Bye everybody! ...and sorry for my poor english...



  • jnethercutt

    Thanks, including comsuppwd.lib worked for me

  • Mark Milan

    Its not enough to define the directoy under options to force the linker to use a library. Add comsupp.lib to the linker input options.

  • califman1849


    #ifdef _DEBUG

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

    #else

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

    #endif

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


    that worked like a charm. right in stdafx.h under a #pragma once.

    thank-you



  • Sergei Dorogin

    Somehow, my reply to myself was marked as the answer.  It was not.  It was more information.

    I still cannot get this to compile.

  • error LNK2019 related to ConvertStringToBSTR