title: gcc "relocation R_X86_64_PC32 against symbol `ff_M24A'" error when linking statically against ffmpeg on linux
body: <p>I am trying to build a JNI shared library which statically links to ffmpeg.</p>
  
  <p>But at the linking stage, gcc fails with the following error:</p>
  
  <p><code>/usr/bin/ld: ./lib_lin64/libswscale.a(swscale.o): relocation R_X86_64_PC32 against symbol `ff_M24A' can not be used when making a shared object; recompile with -fPIC
  </code></p>
  
  <p>I am using the following commands to compile my jni library:</p>
  
  <p><code>gcc -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I ./include -fPIC -c *.c</code><br>
  <code>gcc -shared -Wl,--no-undefined -o libnv_avc_dec.so *.o -Wl,-Bstatic -L./lib_lin64 -lavcodec -lavutil -lswresample -lswscale -Wl,-Bdynamic -lm
  </code></p>
  
  <p>And I only use h264 decoding feature, so I am also building ffmpeg from source with the minimal required feature set. The ./configure command I use is:</p>
  
  <p><code>./configure \
  --enable-pic --prefix=ffmpeg-dist \
  --disable-debug --enable-version3 --enable-gpl \
  --disable-everything --enable-hwaccel=h264_vdpau --enable-hwaccel=h264_vaapi --enable-hwaccel=h264_qsv --enable-hwaccel=h264_mmal \
  --enable-decoder=h264 --enable-decoder=h264_vdpau --enable-decoder=h264_crystalhd --enable-decoder=h264_mmal --enable-decoder=h264_qsv \
  --disable-iconv --disable-securetransport --disable-xlib --disable-zlib --disable-lzma  --disable-bzlib  --disable-doc --disable-programs --disable-avformat --disable-avfilter --disable-postproc
  </code></p>
  
  <p>So, as I understand, the linker tells me that ffmpeg should be compiled with -fPIC flag in order to make a shared library. But I believe that I've already done so by specifying the --enable-pic configure flag. And I am pretty much stuck here because I am not very familiar with autotools, nor with ffmpeg build process in particular.</p>
  
  <p>If this is the issue of ffmpeg .a libs not being compiled with -fPIC flag, how can i force it? And if this is not the case, what am i doing wrong and how can i fix this error?</p>
  
  <p>Environment details: Ubuntu 14.04.3 64-bit in Virtualbox, gcc 4.8.5 and 5.3 (both give the same results), ffmpeg v.2.8.5</p>