Open MPI logo

Hardware Locality Users' Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Users mailing list

Subject: [hwloc-users] How to build hwloc static to link into a shared lib on Linux
From: Robin Scher (robin_at_[hidden])
Date: 2014-01-18 01:23:21


I’m trying to build hwloc (1.8) on Linux (CentOS 6 x64) as a static library that will be linked into my own shared library that is part of my application. I am not using very much of hwloc, and I am trying to avoid having the full hwloc shared library distributed with my application just for the tiny bit of it that I am using. However, this turns out to be a challenge.

I configured with:

./configure --enable-static --disable-shared

which builds the static library just fine, but when I link it to my shared library I get this error:

/usr/bin/ld: /usr/local/lib/libhwloc.a(topology.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

So, I tried re-configuring:

./configure --enable-static --disable-shared CXXFLAGS=-fPIC

but after rebuilding the library, I still get the same link error.

Is this a possible configuration? I can make my app work with hwloc in its own shared library distributed with my app, it just seems so wasteful for what I’m doing with it. I’m not the biggest Linux expert, so I’m pretty sure I’m doing something wrong, but I have managed to get other libraries I’m using (boost.regex and zeromq) to work this way, so it seems like it should be possible.

Thank you for any help you can provide.

Robin Scher
+1 (213) 448-0443