locked
StringCchVPrintfA issue RRS feed

  • Question

  • I use StringCchVPrintfA to output a formated string. I include strsafe.h, but receive a linker error:

    error LNK2019: unresolved external symbol __vsnprintf_s referenced in function "long __stdcall StringVPrintfWorkerA(char *,unsigned int,char const *,char *)"

    My application is build without CRT. How to fix this error?

    Wednesday, July 4, 2012 8:16 AM

Answers

  • On 04/07/2012 10:16, Terminus Amulius wrote:

    I use StringCchVPrintfA to output a formated string. I include strsafe.h, but receive a linker error:

    error LNK2019: unresolved external symbol __vsnprintf_s referenced in function "long __stdcall StringVPrintfWorkerA(char *,unsigned int,char const *,char *)"

    My application is build without CRT. How to fix this error?

    You may want to build with the CRT, as the StringVPrintfWorkerA() function seems to depend on _vsnprintf_s which is exported by the CRT.

    Why do you build without the CRT, if you don't mind me to ask?

    If it is for deployment problems (e.g. you don't want your user to install VC redistributable DLL's), you could just use static linking with CRT.

    Giovanni

    Wednesday, July 4, 2012 8:22 AM

All replies

  • On 04/07/2012 10:16, Terminus Amulius wrote:

    I use StringCchVPrintfA to output a formated string. I include strsafe.h, but receive a linker error:

    error LNK2019: unresolved external symbol __vsnprintf_s referenced in function "long __stdcall StringVPrintfWorkerA(char *,unsigned int,char const *,char *)"

    My application is build without CRT. How to fix this error?

    You may want to build with the CRT, as the StringVPrintfWorkerA() function seems to depend on _vsnprintf_s which is exported by the CRT.

    Why do you build without the CRT, if you don't mind me to ask?

    If it is for deployment problems (e.g. you don't want your user to install VC redistributable DLL's), you could just use static linking with CRT.

    Giovanni

    Wednesday, July 4, 2012 8:22 AM
  • As Giovanni suggested, If you use  CRT, you use the /MDd parameter in your project.

    Please find the following from MSDN, 

    To set this compiler option in the Visual Studio development environment

    1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
    2. Click the C/C++ folder.
    3. Click the Code Generation property page.
    4. Modify the Runtime Library property.


    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/


    • Edited by Selvam Wednesday, July 4, 2012 9:51 AM
    Wednesday, July 4, 2012 9:50 AM
  • On 04/07/2012 11:50, Selvam wrote:

    As Giovanni suggested, If you use  CRT, you use the /MDd parameter in your project.

    Sorry, but there must be some misunderstanding.

    I suggested that the OP may want to statically link with the CRT to make the deployment easier. The compiler option for statically linking with CRT is /MT for release builds:

    http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=vs.100).aspx

    Giovanni

    Wednesday, July 4, 2012 10:09 AM
  • Is there any function that do the same job without CRT?
    Thursday, July 12, 2012 1:02 PM
  • On 7/12/2012 9:02 AM, Terminus Amulius wrote:

    Is there any function that do the same job without CRT?

    wsprintf and wvsprintf are part of Windows API (exported from user32.dll), and shouldn't require CRT.


    Igor Tandetnik

    Thursday, July 12, 2012 3:39 PM