Recompiling with -fPIC

蓝咒 提交于 2019-12-05 01:23:06

问题


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.


回答1:


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.




回答2:


It's also possible that this is a symptom and not the problem. Take a look at this answer and see if it helps (how to recompile with -fPIC). As of MPICH 3.0.4, the default is to build with shared libraries instead of static, so you may need to make sure that they're consistent.




回答3:


The ultimate answer is going to depend on the makefiles in question but using make CFLAGS=-fPIC might work as might MYCFLAGS or any of a number of other such variables. You'll have to look and see what Qthreads is using to create that archive.



来源:https://stackoverflow.com/questions/18387247/recompiling-with-fpic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!