Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6635781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:05:58+00:00 2026-05-25T23:05:58+00:00

Why is -rdynamic not exporting the symbols in .a files but is exporting the

  • 0

Why is -rdynamic not exporting the symbols in .a files but is exporting the symbols in .o files ?

I have an app and a plug-in in a .so file. The main app is linked using a series of object files and one static library, like this:

CXXFLAGS =      $(CXXFLAGS_COMMON) -rdynamic
STATICLIBS =    ../Utilities/Utilities.a
...

all:
    $(CXX) $(CXXFLAGS) -o $(SAMPLE) main.o $(STATICLIBS) $(SHAREDLIBS) $(INCLUDES)

(CXX is g++ 4.5.2 on Ubunut, I use mainly -std=c++Ox for compilation)

In this case, the symbols in Utilities.a are not exported (i.e. “objdump -t a.out | grep symbol” is empty).

If I use “ar x” to extract the .o files in the .a and link using only the .o’s, then the symbols are exported and found by the plug-ins (that are loaded with dlopen in case you wondered).

I have tried using -Wl,-export-dynamic but without success.

I do have a workaround, as mentionned, but I’d still wish to understand what I am missing. Thanks in advance !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:05:59+00:00Added an answer on May 25, 2026 at 11:05 pm

    Normally, the linker only includes those parts of static archives (.a files) which are referenced.

    To force the linker to include the entire contents of a .a file, you can use the --whole-archive linker option (so -Wl,--whole-archive on the gcc command line).

    Note that -Wl,--whole-archive is position-sensitive on the command line — it only affects .a files following it on the command line. Its effect may be subsequently turned off using -Wl,--no-whole-archive, if there are further static archives which you don’t want to be completely included.

    So, for instance, with your command:

    $(CXX) $(CXXFLAGS) -o $(SAMPLE) main.o -Wl,--whole-archive $(STATICLIBS) -Wl,--no-whole-archive $(SHAREDLIBS) $(INCLUDES)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an executable that loads .so plugins. The executable is linked with -rdynamic
I need to dynamically link a library that I have created. I'm not exactly
It appears to be looking for the libmagic.so.1 file. I have that file. It
I'm trying to do a debug build of the Rabbyt library using mingw's gcc
I have the following code fragment: template <class T> struct ServicePtr { std::shared_ptr<T> service;
I believe the conftest lacks the correct flags, but I'm unable to figure out
I have a program in c++ that was working and compiling on ubuntu 10.10.
I'm having a link error under cmake that I don't have when compiling on
The way my team's project is developed, we generate a Shared Object library for
First of all, I have seen this (<- a link), and it isn't working.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.