title: undefined reference to 'mbstowcs_s'
body: <p>This is my code. I want to test function mbstowcs_s.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;wchar.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;locale.h&gt;
  #include &lt;assert.h&gt;
  
  
  int main()
  {
      char MultiByteStr[20] = "a中";
      wchar_t WideByteStr[20];
  
      printf("%s\n", MultiByteStr);
  
      char* LocaleInfo = setlocale(LC_CTYPE, "");
      printf("%s\n", LocaleInfo);
  
      // required length of WideByteStr
      size_t WideStrLen = 0;
      mbstowcs_s(&amp;WideStrLen, NULL, 0, MultiByteStr, 0);
      assert(WideStrLen &lt; 20);
      mbstowcs_s(NULL, WideByteStr, 20, MultiByteStr, WideStrLen);
      WideByteStr[WideStrLen] = L'\0';
      wprintf(L"%ls\n", WideByteStr);
  
      return 0;
  }
  </code></pre>
  
  <p>I test this code on windows platform successfully, but failed on linux platform. Below is the error message.</p>
  
  <pre><code>test.c: In function ‘main’:
  test.c:20:5: warning: implicit declaration of function ‘mbstowcs_s’ [-Wimplicit-function-declaration]
       mbstowcs_s(&amp;WideStrLen, NULL, 0, MultiByteStr, 0);
       ^
  /tmp/ccqzP6HF.o: In function `main':
  test.c:(.text+0x77): undefined reference to `mbstowcs_s'
  test.c:(.text+0xc3): undefined reference to `mbstowcs_s'
  collect2: error: ld returned 1 exit status
  </code></pre>