title: mingw linker error when using vector templates
body: <p>I'm using MinGw on Windows 7. The following simple program compiles fine, but the linker complains and I do not understand what's wrong:</p>
  
  <pre><code>#include &lt;iostream&gt;   
  #include &lt;vector&gt;
  
  using namespace std;
  
  int main()
  {
     std::vector&lt;int&gt; iv;
     iv.push_back(7);
     cout &lt;&lt; iv.back() &lt;&lt; endl;
     return 0;
  }
  </code></pre>
  
  <p>the compiler/linker messages look as follows:</p>
  
  <pre><code>mingw32-g++.exe -Wall -fexceptions  -std=c++0x -Wall -g  -std=c++0x -Wall -g -frepo   -IC:\cppbuchincludes\include -IG:\Boost -IG:\Users\thomas\cpp\STLUsage\\include  -c G:\Users\thomas\cpp\STLUsage\main.cpp -o obj\Debug\main.o
  mingw32-g++.exe  -o bin\Debug\STLUsage.exe obj\Debug\main.o    G:\Boost\stage\lib\libboost_filesystem-mgw45-mt-d-1_45.dll.a G:\Boost\stage\lib\libboost_regex-mgw45-mt-d-1_45.dll.a G:\Boost\stage\lib\libboost_system-mgw45-mt-d-1_45.dll.a G:\Boost\stage\lib\libboost_thread-mgw45-mt-1_45.dll.a G:\Boost\stage\lib\libboost_unit_test_framework-mgw45-mt-d-1_45.dll.a
  collect: recompiling G:\Users\thomas\cpp\STLUsage\main.cpp
  collect: relinking
  collect2: '_ZNSt12_Vector_baseIiSaIiEEC1Ev' was assigned to 'obj\Debug\main.rpo', but was not defined during recompilation, or vice versa
  obj\Debug\main.o: In function `vector':
  c:/mingw/bin/../lib/gcc/mingw32/4.5.2/include/c++/bits/stl_vector.h:208: undefined reference to `std::_Vector_base&lt;int, std::allocator&lt;int&gt; &gt;::_Vector_base()'
  (...and so on...)
  </code></pre>
  
  <p>I can use templates I defined myself. </p>
  
  <p>I have that MinGw binary from a book and followed the instructions in that book regarding compiler settings. In particular the references to the Boost libs are taken from there. </p>
  
  <p>This must be a simple thing, I just want to make trivial use of the STL.</p>
  
  <p><strong>Edit</strong> following the advice given in an answer, I replaced the binary to be used to compile by g++.exe in the Settings -> Compiler and debugging -> toolchain executables dialog, but I'm getting the same error messages (with mingw32-g++.exe now replaced by g++.exe).</p>
  
  <p><strong>Edit</strong> (once more) this has to be problem eith the Code::Blocks settings, since compiling using g++ from the command line works just fine.</p>