What does gcc linking option / LOCAL\_CFLAGS -rdynamic do


I am working on an android NDK project. When I try to modify the project file (Android.mk) I found the linking option -rdynamic after reading the reference, I still not sure the meaning of the flag.

The project I am working on. It has two parts: – Multiple client applications. – Multiple shared libraries. (each client has a corresponding shared library) – Background daemon processes: a process manager and a launcher.

First, a client application. Once the client starts to run, it is able to communicate with the manager process. The manager will use dlopen() to load corresponding shared library based on the launcher process. After that, the manager will create a new launcher process.

I felt that the link flag has something to do with the background process, but not sure.


Pass the flag -export-dynamic to the ELF linker, on targets that support it. This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table. This option is needed for some uses of dlopen or to allow obtaining backtraces from within a program.


Adding -rdynamic to LOCAL_CFLAGS will do nothing, as -rdynamic is a linker flag. You need to add it to LOCAL_LDFLAGS.

For a more thorough explanation of -rdynamic, see https://stackoverflow.com/a/12636790/632035 (I know the question isn’t the same, but the answer explains the flag well).

Answered By – Dan Albert

Leave a Comment