title: Can't get libsodium pre-built library for mingw windows to work
body: <p>What I want is, as per <a href="https://download.libsodium.org/doc/usage/" rel="nofollow noreferrer">the documentation</a>, just use this code:</p>
  
  <pre><code>#include &lt;sodium.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;inttypes.h&gt;
  
  int main(void)
  {
      if (sodium_init() == -1) {
          return 1;
      }
      printf("Random data: %"PRIu32"\n", randombytes_random()); //returns a uint32_t piece of random data
      return 0;
  }
  </code></pre>
  
  <p>In the <a href="https://download.libsodium.org/doc/installation/" rel="nofollow noreferrer">installation section</a> for windows of the documentation, it states the precompiled windows version for MinGW32. As I'm using codeblocks with MinGW, I figured that those should work.</p>
  
  <p>I downloaded the <code>libsodium-1.0.13-mingw.tar.gz</code> file and extracted it. I took all the contents of the <code>libsodium-win32</code> folder and put them in the MinGW root <code>C:\Program Files (x86)\CodeBlocks\MinGW</code> (the folders <code>include</code>, <code>bin</code> and <code>lib</code> match up as well, making me believe this is the proper way to go).</p>
  
  <p>I then make a new project in codeblocks with the code snippet from above and compile with -std=c99 (although -std=gnu99 doesn't make a difference) and get the following warning:</p>
  
  <pre><code>*filepath*\testsodium\main.c  8    undefined reference to 'sodium_init'
  *filepath*\testsodium\main.c  11   undefined reference to 'randombytes_random'
  </code></pre>
  
  <p>Which indicates to me that it for some reason can't find or doesn't actually include the <code>&lt;sodium.h&gt;</code>. What's weird is that if I just take <code>sodium_init()</code> (without checking the output in an <code>if</code> statement), it gives me a warning stating:</p>
  
  <pre><code>*filepath*\testsodium\main.c  8     warning: ignoring return value of 'sodium_init', declared with attribute warn_unused_result [-Wunused-result]
  </code></pre>
  
  <p>Which indicates to me that it does actually gets parsed as it notices the lack of checking the result. Checking the build log I find that <code>mingw32-gcc.exe</code> throws the <code>-Wunused-result</code> warning while <code>mingw32-g++</code> throws the error.</p>
  
  <pre><code>-------------- Build: Debug in testsodium (compiler: GNU GCC Compiler)---------------
  
  mingw32-gcc.exe -Wall -g -Wall -std=c99  -c 
  *filepath*\testsodium\main.c -o obj\Debug\main.o
  *filepath*\testsodium\main.c: In function 'main':
  *filepath*\testsodium\main.c:8:5: warning: ignoring return value of 'sodium_init', declared with attribute warn_unused_result [-Wunused-result]
   sodium_init();
   ^
  mingw32-g++.exe  -o bin\Debug\testsodium.exe obj\Debug\main.o   
  obj\Debug\main.o: In function `main':
  
  *filepath*/testsodium/main.c:8: undefined reference to `sodium_init'
  *filepath*/testsodium/main.c:9: undefined reference to `sodium_init'
  *filepath*/testsodium/main.c:12: undefined reference to `randombytes_random'
  collect2.exe: error: ld returned 1 exit status
  Process terminated with status 1 (0 minute(s), 0 second(s))
  4 error(s), 1 warning(s) (0 minute(s), 0 second(s))
  </code></pre>
  
  <hr>
  
  <p>Can somebody help me figure out how to get sodium to work on my setup?</p>