locked
error LNK2019 related to ConvertStringToBSTR RRS feed

  • Question

  • 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 ==========

    Wednesday, November 23, 2005 6:18 PM

Answers

  • 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.
    Saturday, November 26, 2005 7:57 PM

All replies

  • 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.
    Wednesday, November 23, 2005 6:29 PM
  • Somehow, my reply to myself was marked as the answer.  It was not.  It was more information.

    I still cannot get this to compile.
    Saturday, November 26, 2005 4:39 PM
  • 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.
    Saturday, November 26, 2005 7:57 PM
  • 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.

    Tuesday, July 11, 2006 9:15 PM
  • 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

    Tuesday, August 15, 2006 11:07 AM
  • Thanks, including comsuppwd.lib worked for me
    Friday, December 8, 2006 10:39 PM
  • 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.
    Tuesday, March 13, 2007 9:36 AM
  • 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...

    Sunday, March 18, 2007 8:46 PM
  •  

    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

     

     

    Tuesday, November 13, 2007 1:41 PM
  • Thanks a ton it worked for me .........Smile

     

    Saturday, January 19, 2008 2:15 PM

  • #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


    Friday, February 8, 2008 2:36 PM
  •  

    I had the same error and indeed what is written above fixes the problem

     

    In fact in the header "comdef.h" on line 31 there is only:

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

    Wednesday, September 3, 2008 7:39 PM
  • Thanks a bunch. Ran into a similar problem with  VC 6.0 project migrated to VC++ 2005. Adding the below lines Stdafx.h resolved the linker error.

    #ifdef
    _DEBUG

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

    #else

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

    #endif

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

    Friday, December 4, 2009 1:09 AM
  • I just had a similar issue with VS2005.

    I had installed the Platform SDK and set up the VC++ directories so it was first in the list.

    I resolved my issue by putting it after the VS version of the SDK.

     

    Wednesday, March 31, 2010 11:30 PM
  • use comsuppw.lib
    Avinash
    Thursday, October 28, 2010 10:37 AM