title: linker error "relocation R_X86_64_PC32 against undefined symbol" despite compilation with -fPIC
body: <p>I'm compiling a c++ program using the command line</p>
  
  <pre><code>g++ -c prog.cc -std=c++11 -march=native -fPIC -fopenmp
  </code></pre>
  
  <p>and then try to make a shared object via</p>
  
  <pre><code>g++ prog.o -shared -fopenmp -o lib/libprog.so
  </code></pre>
  
  <p>This has always worked. But today I get:</p>
  
  <pre><code>/usr/bin/ld: prog.o: relocation R_X86_64_PC32 against undefined symbol 
    `_ZTVN12_GLOBAL__N_111handle_baseE' can not be used when making a shared
    object; recompile with -fPIC
  /usr/bin/ld: final link failed: Bad value
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>The symbol <code>_ZTVN12_GLOBAL__N_111handle_baseE</code> de-mangles to
  <code>vtable for (anonymous namespace)::handle_base</code>
  (<code>handle_base</code> is a polymorphic class defined in the anonymous namespace in prog.cc and yes I do call <code>dynamic_cast&lt;handle_base&gt;()</code>.)</p>
  
  <p>I'm using gcc version 4.7.0 (GCC) and GNU ld (GNU Binutils; openSUSE 11.1) 2.19. Can anybody help (suggest solutions [other than doing without shared object or the <code>dynamic cast</code>])?</p>