title: Linker settings
body: <p>I'm trying to link boost.python with my application in cmake build-system.
  The most important parts in my <strong>CMakeList.txt</strong>:</p>
  
  <pre><code>set(Boost_USE_STATIC_LIBS OFF)
  set(Boost_USE_MULTITHREADED ON)
  set(Boost_USE_STATIC_RUNTIME OFF)
  
  find_package(Boost COMPONENTS filesystem system date_time python REQUIRED)
  
  add_definitions(-Wall -g -msse2 -fPIC)
  </code></pre>
  
  <p>And, of course, including/linking boost's and python's libraries/headers.</p>
  
  <p>Now this fails with:</p>
  
  <pre><code>/usr/bin/ld: libboost_python.a(from_python.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
  libboost_python.a: could not read symbols: Bad value
  </code></pre>
  
  <p>I decided to go to the cmake temporary build folder and find generated <strong>object file (*.o)</strong>.
  I've applied command for it:</p>
  
  <pre><code>g++ -shared FILE.cpp.o -L/usr/lib -lboost_python -o MyModule.so
  </code></pre>
  
  <p>As a result I got workable MyModule module for python! So, lets look at cmake linker string and find the difference. I ran make with <strong>VERBOSE=1</strong>:</p>
  
  <pre><code>/usr/bin/c++  -fPIC -g  -shared -Wl,-soname,libScript.so -o ../../lib/libScript.so CMakeFiles/LogManagerWrapper.cpp.o -Wl,-Bstatic -lboost_filesystem -lboost_system -lboost_date_time -lboost_python -Wl,-Bdynamic -lpython2.7 
  </code></pre>
  
  <p>During excluding some parts of  the linker flags I found that my problem is in <strong>-Wl,-Bstatic</strong> before boosts' libraries list.</p>
  
  <p>I wonder from where that argument came because I noticed <strong>Boost_USE_STATIC_LIBS OFF</strong> in CMakeList.txt.</p>
  
  <p>What's wrong?</p>