title: How to use Mersenne Twister random number generation library in C?
body: <p>I want to use one of the Mersenne Twister C libraries (e.g. <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/TINYMT/index.html" rel="nofollow">tinymt</a>, <a href="http://www.cs.hmc.edu/~geoff/mtwist.html" rel="nofollow">mtwist</a>, or libbrahe) <strike>so I can use it as a seed for <code>rand()</code></strike> in a C program. I wasn't able to find a simple minimalistic example on how to do this.</p>
  
  <p>I got this far with the mtwist package, but through pjs's comments I've realized that this is the wrong way to do it:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include "mtwist.h"
  
  int main() {
      uint32_t random_value;
  
      random_value = mt_lrand();
      srand(random_value);
      printf("mtwist random: %d; rand: %d\n", random_value, rand());
  
      return 0;
  }
  </code></pre>
  
  <p>(Originally I wrote that this code wouldn't compile, but thanks to Carl Norum's answer I was able to compile it afterall.)</p>
  
  <p>Could anyone give me a simple example on how to properly generate random numbers with any Mersenne Twister C library?</p>