title: Linking Boost libs in CodeBlocks (using MinGW)
body: <p>For almost three days now I have been trying to get the boost libs working properly in CodeBlocks using mingw. In between many of the problems that I managed to fix by myself, now I'm stuck and it's driving me mad.</p>
  
  <p>I have built the library many many times with different flags sent to <code>bjam</code> but every time I use these libs in CodeBlocks I get the same result. A lot of lines with</p>
  
  <pre><code>undefined reference to `___gxx_personality_sj0'
  undefined reference to `__Unwind_SjLj_Register'
  undefined reference to `__Unwind_SjLj_Resume'
  undefined reference to `__Unwind_SjLj_Unregister'
  </code></pre>
  
  <p>Before people start lashing out at me, I have searched for the problem before coming here. Almost all the threads (<a href="https://stackoverflow.com/questions/7751640/undefined-reference-to-gxx-personality-sj0">here</a> and <a href="https://stackoverflow.com/questions/2189681/undefined-references-when-trying-to-link-qt-app-with-my-static-library">here</a> and others) say that this problem comes from the fact that boost was built with a compiler and now I am trying to use another different compiler in CodeBlocks. I have checked time and time again and I only have one <code>MinGW</code> installation available. I have checked my <code>Path</code> variable and nothing unwanted is in there, only the bin folder of the MinGW that I want to use. I don`t have any QT installation so no second MinGW from there. Also, I downloaded the CodeBlocks <strong>without</strong> the bundled MinGW.</p>
  
  <p>Below I will list the steps I take:</p>
  
  <p>1) <code>bootstrap.bat mingw</code> which builds bjam</p>
  
  <p>2) <code>bjam --toolset=gcc "--prefix=&lt;installpath&gt;" install</code> as stated <a href="http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef" rel="nofollow noreferrer">here</a></p>
  
  <p>3) follow the rest of the steps from the link from step 2)</p>
  
  <p>4) add <code>Boost.Filesystem</code>, <code>Boost.System</code>, <code>Boost.DateTime</code>, <code>Boost.Thread</code> and <code>Boost.Regex</code> (dependencies for Boost.Log taken from <a href="http://boost-log.sourceforge.net/libs/log/doc/html/log/installation.html" rel="nofollow noreferrer">here</a>)</p>
  
  <p>5) copy/paste <a href="http://boost-log.sourceforge.net/libs/log/doc/html/log/tutorial.html#log.tutorial.trivial" rel="nofollow noreferrer">this example</a></p>
  
  <p>The command that CodeBlocks uses when I try to Build:</p>
  
  <blockquote>
    <p>mingw32-g++.exe -Wall -fexceptions  -g<br>
    -ID:\libs\boost\include\boost-1_51  -c D:\example\example\main.cpp -o obj\Debug\main.o</p>
    
    <p>mingw32-g++.exe -LD:\libs\boost\lib  -o bin\Debug\example.exe
    obj\Debug\main.o
    D:\libs\boost\lib\libboost_filesystem-mgw44-mt-d-1_51.a
    D:\libs\boost\lib\libboost_system-mgw44-mt-d-1_51.a
    D:\libs\boost\lib\libboost_date_time-mgw44-mt-d-1_51.a
    D:\libs\boost\lib\libboost_thread-mgw44-mt-1_51.a
    D:\libs\boost\lib\libboost_regex-mgw44-mt-d-1_51.a
    D:\libs\boost\lib\libboost_log_setup-mgw44-mt-d-1_51.a</p>
  </blockquote>
  
  <p>What else could be the cause of this?</p>
  
  <p><strong>Later added:</strong></p>
  
  <p>CodeBlocks toolchain executables are:</p>
  
  <pre><code>c++ compiler: mingw32-g++.exe
  linker for dynamic libs: mingw32-g++.exe
  linker for static libs: ar.exe
  </code></pre>
  
  <p>All .EXEs are where they should be but added this info maybe it is important.</p>