title: libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9'
body: <p>I am building an shared object file in ubuntu(vagrant) that uses ffmpeg libraries(libavcodec.a, libavformat.a, libavutil.a). I first used the standard configure options to build ffmpeg and libraries from <a href="https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu" rel="nofollow noreferrer">trac.ffmpeg</a>. But there was some issues with dynamic linking and I modified the configure options a little bit to add <code>--enable-shared</code> and <code>-fPIC</code> options.</p>
  
  <pre><code>However when I build my application I get 
  /usr/bin/ld: /root/ffmpeg_build/lib/libavcodec.a(vc1dsp_mmx.o): 
  relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when
   making a shared object; recompile with -fPIC
  /usr/bin/ld: final link failed: Bad value
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I used the following options in my configure to build ffmpeg</p>
  
  <pre><code>PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig:$PKG_CONFIG_PATH" ./configure \
    --prefix="$HOME/ffmpeg_build" \
    --pkg-config-flags="--static" \
    --extra-cflags="-I$HOME/ffmpeg_build/include -fPIC" \
    --extra-ldflags="-L$HOME/ffmpeg_build/lib -Wl,-Bsymbolic" \
    --extra-libs="-lpthread -lm" \
    --bindir="$HOME/bin" \
    --enable-gpl \
    --enable-libass \
    --enable-libfdk-aac \
    --enable-libfreetype \
    --enable-libmp3lame \
    --enable-libopus \
    --enable-libvorbis \
    --enable-libvpx \
    --enable-libx264 \
    --enable-libx265 \
    --enable-nonfree \
    --enable-pic \
    --enable-shared
  </code></pre>
  
  <p>The build works fine on my MAC. </p>
  
  <p>The following is my cmake file to build my application</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.5)
  project(extractor C)
  
  set(CMAKE_C_STANDARD 99)
  
  set(EXECUTABLE_NAME "extractor")
  
  set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)
  
  set(EXTRACTOR_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  set(target_dir "bin")
  
  # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=99")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
  # set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
  
  
  add_library(${EXECUTABLE_NAME} SHARED src/frame_extractor.c)
  
  include_directories(".")
  find_package(FFmpeg REQUIRED)
  
  if (FFMPEG_FOUND)
      message("Found FFMPEG/LibAV libraries ${FFMPEG_LIBRARIES}")
          message("include dirs ${FFMPEG_INCLUDE_DIR}")
      include_directories(${FFMPEG_INCLUDE_DIR})
      target_link_libraries(${EXECUTABLE_NAME} ${FFMPEG_LIBRARIES})
  else (FFMPEG_FOUND)
      message("cant find libavcodec, libavformat or libavutil. add them manually!!")
  endif (FFMPEG_FOUND)
  
  target_link_libraries(${EXECUTABLE_NAME} ${FFMPEG_LIBRARIES})
  # target_link_libraries (${EXECUTABLE_NAME} "-lm")
  # target_link_libraries (${EXECUTABLE_NAME} "-lavcodec")
  
  if(APPLE)
      #target_link_libraries(${EXECUTABLE_NAME} "-framework CoreServices")
      #target_link_libraries(${EXECUTABLE_NAME} "-framework CoreFoundation")
      #target_link_libraries(${EXECUTABLE_NAME} "-framework AudioToolbox")
      #target_link_libraries(${EXECUTABLE_NAME} "-framework VideoToolbox")
      #target_link_libraries(${EXECUTABLE_NAME} "-framework CoreAudio")
      #target_link_libraries(${EXECUTABLE_NAME} "-framework CoreMedia")
      #target_link_libraries(${EXECUTABLE_NAME} "-framework CoreVideo")
      #target_link_libraries(${EXECUTABLE_NAME} "-framework AVFoundation")
      #target_link_libraries(${EXECUTABLE_NAME} "-framework Security")
      #target_link_libraries(${EXECUTABLE_NAME} /usr/lib/libbz2.1.0.dylib)
      #target_link_libraries(${EXECUTABLE_NAME} /usr/lib/libz.1.dylib)
      #target_link_libraries(${EXECUTABLE_NAME} /usr/lib/libiconv.dylib)
      #target_link_libraries(${EXECUTABLE_NAME} /usr/lib/liblzma.dylib)
      #target_link_libraries(${EXECUTABLE_NAME} /usr/local/lib/libswresample.a)
      #target_link_libraries(${EXECUTABLE_NAME} /usr/local/Cellar/fdk-aac/0.1.6/lib/libfdk-aac.dylib)
      #target_link_libraries(${EXECUTABLE_NAME} /usr/local/lib/libx264.dylib)
  endif(APPLE)
  # Add python dependencies -
  # ERROR - It picks up the default version from the machine which is 2.7.10
  find_package( PythonInterp 2.7 REQUIRED)
  find_package(PythonLibs 2.7 REQUIRED)
  
  
  message("GURU - python include dirs = ${PYTHON_INCLUDE_DIRS}")
  message("GURU - python include dirs = ${PYTHON_LIBRARIES}")
  
  include_directories(${PYTHON_INCLUDE_DIRS})
  target_link_libraries(${EXECUTABLE_NAME} ${PYTHON_LIBRARIES})
  
  
  
  # Apple creates annoying dylib extension for shared libraries
  if(APPLE)
      SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
  endif(APPLE)
  set(CMAKE_SHARED_LIBRARY_PREFIX "")
  </code></pre>
  
  <p>Thanks a lot for any help in resolving this.</p>