2

I recently built Monero from master on Manjaro, and there were no issues. I then built the same commit on an Ubuntu computer and received an error about fPIC.

Like ... .rodata' can not be used when making a shared object; recompile with -fPIC

Note that the Ubuntu dependencies had previously been installed via apt package manager. Similarly, the Manjaro dependencies had been installed via pacman package manager. Also, Ubuntu (Lubuntu) is actually 16.04.3 LTS, and Manjaro is 17.1.5.

Also note: I successfully built by editing CMakeLists.txt and commenting out set(PIC_FLAG "-fPIC") and add_linker_flag_if_supported(-pie LD_SECURITY_FLAGS) (not 100% sure the second one was needed). I'd rather just recompile with fPIC, but I don't quite understand what that entails.

Side question: what is it about Manjaro that prevented this fPIC issue?

Real question: how do I go about fixing my dependencies to deal with fPIC?

2
  • Does this help? Commented Feb 18, 2018 at 3:18
  • Sort of, yeah. Thank you. I'll post how I solved the problem for myself, though I'm curious about other solutions. Commented Feb 20, 2018 at 1:37

2 Answers 2

3

I did this to recompile libgtest-dev with -fPIC and it worked for me.

sudo apt-get install libgtest-dev
cd /usr/src/gtest/
sudo cmake -DCMAKE_CXX_FLAGS="-fPIC"
sudo make
sudo mv libg* /usr/lib/
2

The problem being experienced has to do with how the compiler uses libraries.

As noted in the github link provided by Florian, one solution to this problem is simply to uninstall libgtest-dev. This actually didn't work the first time I tried to make. Once I did make clean first, it worked as intended.

Another solution is so comment out the lines of CMakeLists.txt that require -fPIC. Those were noted in the question.

This answer does not address whether compiling libgtest-dev with -fPIC would also solve the problem, if so, how to do that.

1
  • 1
    It would. And you'd get the source .deb, twiddle the CFLAGS, and PR that to the libgtest-dev maintainer.
    – user36303
    Commented Feb 20, 2018 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.