title: Relocation R_X86_64_32S against `.rodata' ... While compiling on 64-bit platform
body: <p>So I've been coding something on 32-bit and yesterday I needed to build a dll and I had a couple of problems with that. Anyway I solved them <a href="https://stackoverflow.com/questions/9593286/creating-a-library-file-in-makefile-and-compiling-after-that">here</a>.</p>
  
  <p>Unfortunately even if I thought that everything was working after all I found that wasn't the case when I moved my program and makefile on other computer what runs on 64bit, as you can guess what happened...</p>
  
  <p>So my problem is related to relocation because of 64bit</p>
  
  <pre><code>/usr/bin/ld: MyClass.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
  MyClass.o: could not read symbols: Bad value
  </code></pre>
  
  <p>and here is my makefile</p>
  
  <pre><code>MyProgram: main.o chkopts
      -${CLINKER} -o $@ $&lt; ${MYLIB} ${PETSC_MAT_LIB}
      ${RM} main.o
  
      export LD_LIBRARY_PATH=${LIBADD}:$LD_LIBRARY_PATH
  
  LibMyProgram.so: MyClass.o  chkopts
      -${CLINKER}  -shared -Wl,-soname,${SONAME} -o ${VERS}   *.o  ${PETSC_MAT_LIB}
  
      mv ${VERS} ${LIBADD}
      ln -sf ${LIBADD}${VERS} ${LIBADD}${SOWOV}
      ln -sf ${LIBADD}${VERS} ${LIBADD}${SONAME}
  </code></pre>
  
  <p>I've tried to add -fPIC in CFLAGS, CPPFLAGS and even LDFLAGS. I've also tried add -fPIC before and after -shared flag.</p>
  
  <pre><code>-${CLINKER} -shared -fPIC -Wl,-soname,${SONAME} -o ${VERS}   *.o  ${PETSC_MAT_LIB}
  </code></pre>
  
  <p>But I'll just get a same error as previously.</p>
  
  <p>If I use CFLAGS = -fPIC I'll get a bit same kind of error which is:</p>
  
  <pre><code>.../petsc/petsc-3.2-p6/arch-linux2-cxx-debug/lib/libpetsc.a(err.o): relocation R_X86_64_32 against `ompi_mpi_comm_self' can not be used when making a shared object; recompile with -fPIC.
  </code></pre>
  
  <p>I've read about all the topics what are even remotely similar with my problem but I've been unable to figure this out.</p>