Home > Backend Development > C++ > body text

Why does recompiling with -fPIC resolve linking errors?

Linda Hamilton
Release: 2024-11-07 05:04:02
Original
997 people have browsed it

Why does recompiling with -fPIC resolve linking errors?

Recompiling with -fPIC: Resolving Linking Errors

Recompiling with -fPIC is necessary when encountering the error "relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object." This error occurs when linking an object file with a restricted symbol, which cannot be used when combined with a shared object.

To successfully address this issue and recompile with -fPIC:

  • Disable Static and Dynamic Libraries: Despite the compiler's suggestion, disabling both static and dynamic libraries may be a more direct solution. Select the method that best suits your requirements.
  • Enable Shared Libraries: An alternative approach is to enable shared libraries when configuring the software. This can be achieved by adding the --enable-shared option to the ./configure commands, ensuring the compilation of a dynamic library (e.g., .so) instead of a static library (e.g., .a).

By implementing these steps, you can recompile your ffmpeg with -fPIC, thereby resolving the linking error and enabling successful compilation of your program that utilizes the ffmpeg library.

The above is the detailed content of Why does recompiling with -fPIC resolve linking errors?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!