title: Why does gcc not implicitly supply the -fPIC flag when compiling static libraries on x86_64
body: <p>I've had numerous problems compiling shared objects that link statically against static libraries. This problem only shows up on x84_64 platforms. When doing the same compilation work on x86_32 I do not have any problems. </p>
  
  <p>Perhaps this is a OS specific GCC configuration thing, but my research indicates that its how GCC works on x86_64 platforms. Anyhow, I am using gcc 4.4.3 on Ubuntu 10.04 x86_64.</p>
  
  <p>How is the problem fixed ?... Making sure all the static library dependencies are compiled with -fPIC.</p>
  
  <p><strong>Question 1:</strong> What is the difference between -fpic and -fPIC (apparently -fPIC generates more instructions on x86) ? Why is the later type more relevant in the x86_64 context ? </p>
  
  <p><strong>Question 2:</strong> My assumption is that when you link against static code you are hard-wiring the functions into your binary at link time, why does it need the level of indirection the "position independant code" machinery provides ? </p>
  
  <p><strong>Question 3:</strong> Now if x86 doesn't need -fpic / -fPIC to link shared objects against static archives why is it needed in x86_64 ? </p>
  
  <p><strong>Question 4:</strong> even if it is needed why isn't it supplied implicitly ? I thought breaking changes was supposed to be a big no-no</p>