Recompiling with -fPIC

Alex Brooks picture Alex Brooks · Aug 22, 2013 · Viewed 18.5k times · Source

I have MPICH 3.0.4 installed on my machine (Ubuntu 12.04). I am trying to install a library called Qthreads which I have worked with and successfully installed before (except with the MPICH2 package installed). The configuration works fine:

./configure --prefix=/usr/local/qthreads --enable-multinode --with-multinode-runtime=mpi --with-portals4=/usr/local/portals4 --with-hwloc=/usr/local/hwloc:

...
...
...
System Characteristics:
       Target Style: unix
         Multi-node: yes, mpi
       Topology API: hwloc
        Qtimer type: clock_gettime
     Aligned_t size: 8 (aligned on 8 byte boundaries)
 Default Stack size: 4kB

Safety/Debugging:
   Sanity assert()s: no
    Check alignment: no
          Profiling: none
   Debugging Output: no
        Guard Pages: no

Speed:
          Scheduler: sherwood (multiworker shepherds)
         Sinc Style: donecount
      Barrier Style: feb
   Dictionary Style: simple
    Lazy Thread IDs: yes
       Pools/caches: memory, spawns
            RCRTool: no
Increments/CAS/FEBs: Compiler Builtin (both), lock-based hash

When I try and run make, I get the following error:

  ...
  ...
  ...
  CCLD     libqthread.la
/usr/bin/ld: /usr/local/lib/libmpich.a(barrier.o): relocation R_X86_64_32 against `MPIR_ThreadInfo' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libmpich.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libqthread.la] Error 1
make[2]: Leaving directory `/home/alex/Downloads/qthread-1.9/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/alex/Downloads/qthread-1.9/src'
make: *** [all-recursive] Error 1

I have looked around and it seems the obvious (and possible only) solution is to do what the compiler says: recompile with -fPIC. However, I'm hesitant to go through and edit any Makefiles for Qthreads, as they are long and complicated. Is there an easy way to recompile with -fPIC?

Please advise. I appreciate any input.

Answer

Alex Brooks picture Alex Brooks · Aug 23, 2013

After all of the discussion, I did a completely fresh install of MPICH 3.0.4, with --enable-shared being the only configure option given. For some reason it compiled and built successfully, despite not doing so before. After this was accomplished, Qthreads was configured and built successfully without requiring any extra options.