Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build static library with -fPIC #115

Open
paulmenzel opened this issue Jul 11, 2019 · 1 comment
Open

Build static library with -fPIC #115

paulmenzel opened this issue Jul 11, 2019 · 1 comment

Comments

@paulmenzel
Copy link

Trying to build Inkscape 1.x (master branch) with double-conversion, the error below is shown.

[ 87%] Linking CXX shared library ../lib/libinkscape_base.so
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib64/libdouble-conversion.a(double-conversion.cc.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib64/libdouble-conversion.a(fast-dtoa.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib64/libdouble-conversion.a(fixed-dtoa.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib64/libdouble-conversion.a(strtod.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib64/libdouble-conversion.a(bignum.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib64/libdouble-conversion.a(bignum-dtoa.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../lib64/libdouble-conversion.a(cached-powers.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

Should double-conversion be built with -fPIC by default?

@floitsch
Copy link
Collaborator

Hmm.
I'm not an expert on this, but I would expect the inkscape library to use the shared library, instead of the static library.
If you use -DBUILD_SHARED_LIBS=ON when running cmake it should build those.
See https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/double-conversion for how this is done in the arch-linux package.

To be honest, I don't know if static libraries should have the -fPic flag by default. My guess is, that you would integrate static libraries more tightly. Potentially you would end up including the double-conversion library's cmake in the outer cmake file, and configuring it this way (as in https://stackoverflow.com/questions/38296756/what-is-the-idiomatic-way-in-cmake-to-add-the-fpic-compiler-option ).
However, that's just my guess. I will try to ask my coworkers when they are back from vacation.
If you have good resources (with instructions on how this should be done), please post them here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants