I had a lot of problems compiling shared objects that statically set static libraries. This issue only occurs on x84_64 platforms. When doing the same compilation work on x86_32 I have no problems.
This may be a specific GCC configuration for the OS, but my research shows that its GCC runs on x86_64 platforms. Anyway, I am using gcc 4.4.3 on Ubuntu 10.04 x86_64.
How to fix the problem? ... Make sure that all the dependencies of the static library are compiled with -fPIC.
Question 1: What is the difference between -fpic and -fPIC (apparently -fPIC generates more x86 instructions)? Why is the later type more relevant in the x86_64 context?
Question 2: My assumption is that when linking to static code, you rigidly connect functions to your binary code during the connection, why do you need the indirectness level "position-independent code" does the equipment provide?
Question 3: Now, if x86 does not need -fpic / -fPIC to link shared objects with static archives, why is this necessary in x86_64?
Question 4: even if necessary, why is it not provided implicitly? I thought breaking change was supposed to be big, no-no
gcc compilation dynamic-linking static-linking gnu-toolchain
Hassan Syed Oct 18 '10 at 17:00 2010-10-18 17:00
source share