Error While Compiling with ffmpeg: "Relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC"
While attempting to reinstall ffmpeg on an ARM Ubuntu system, a compilation error was encountered when using a program that utilized the ffmpeg library. The error message indicated:
/usr/bin/ld: /usr/local/lib/libavcodec.a(amrnbdec.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libavcodec.a: could not read symbols: Bad value collect2: ld returned 1 exit status
This error arises from an attempt to link a static library (.a) with a dynamic one (.so). To resolve this issue, it is necessary to recompile ffmpeg with the -fPIC flag.
Recompiling with -fPIC
Adding the --enable-shared flag during ./configure will instruct ffmpeg to build as a dynamic library. Alternatively, you can choose to disable static libraries completely if preferred.
Once the ffmpeg library has been recompiled with -fPIC, the compilation should proceed successfully without the aforementioned error.
The above is the detailed content of Why Am I Getting 'Relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object' Error While Compiling ffmpeg?. For more information, please follow other related articles on the PHP Chinese website!