Home > Backend Development > C++ > Why do I get the error 'relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object'?

Why do I get the error 'relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object'?

Barbara Streisand
Release: 2024-11-08 07:00:02
Original
794 people have browsed it

Why do I get the error

Recompilation with -fPIC Flag for ARM Ubuntu Machine

When rebuilding FFmpeg on an ARM Ubuntu machine, one may encounter the error:

relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
Copy after login

This error indicates that the system is attempting to link a static library with a dynamic library, which is incompatible. To resolve this, it is necessary to recompile the problematic library, such as FFmpeg, with the -fPIC flag.

Recompilation Process

The following steps can be taken to recompile a library with the -fPIC flag:

  1. Edit the Library's Source Code: Locate and open the source code files for the library that is causing the relocation error.
  2. Add the -fPIC Flag: Add the -fPIC flag to the compiler options specified in the source code. This flag instructs the compiler to generate position-independent code (PIC), which is suitable for dynamic linking.
  3. Recompile the Library: Rebuild the library using the updated compiler options. This can typically be done using the make command.
  4. Install the Recompiled Library: Once the library has been recompiled with PIC, it should be installed into the system's library directory. This will make it available for linking with other programs.

Specific Example for FFmpeg

For FFmpeg, the following command can be used to recompile it with the -fPIC flag:

./configure --enable-shared --disable-static
make
Copy after login

By adding the --enable-shared flag, shared libraries will be generated instead of static ones. The --disable-static flag ensures that no static libraries are built.

After rebuilding FFmpeg with these options, the recompiled libraries can be installed into the appropriate system directories using make install. This will make the PIC-enabled FFmpeg libraries available for linking and use by other programs.

The above is the detailed content of Why do I get the error 'relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object'?. 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