title: A thread-safe version of the standard C function 'localtime'
body: <p>I am using localtime in a multi-threaded application.</p>
  
  <p>I have to replace it with a thread-safe version, which to my understanding is called localtime_r.</p>
  
  <p>However, when I do so, I am unable to complete the build, due to a linkage failure.</p>
  
  <p>I am not even sure where to start looking for the solution.</p>
  
  <p>My system components are:</p>
  
  <ul>
  <li>Chip - STM32 (ARM based cortex)</li>
  <li>IDE - IAR (compiler and linker for ST-Microcontrollers)</li>
  <li>OS - ThreadX</li>
  </ul>
  
  <p>I'm assuming (though I'm not sure about it), that this function would typically be supplied within the standard libraries provided along with the IDE. Am I correct?</p>
  
  <p>Is there another library that I need to add to my project, or is it something in the project settings?</p>
  
  <p>If there is no viable way to "import" this function into my code, what other options do I have for a thread-safe version of the localtime function?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I am looking to avoid the use of OS resources (i.e., a mutex), and instead call a standard routine which does exactly what 'localtime' does, only without the static structure that it uses (making it thread-unsafe).</p>
  
  <p>I don't see any reason why localtime would use a static structure to begin with, so I assume that the corresponding localtime_r does not solve it with any OS resources whatsoever, but merely refrains the use of a static structure.</p>
  
  <p>If no such option is viable, then I might as well implement it myself, only I prefer to use something that has already been tested properly, due to the "irregularity" of the dating system.</p>
  
  <p>The question here is, how do I link localtime_r' into my project (NOT how to implement localtime_r).</p>
  
  <p>Thanks</p>