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 4274610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:52:13+00:00 2026-05-21T07:52:13+00:00

I’m using the apple gcc to compile a dylib that I’m going to redistribute.

  • 0

I’m using the apple gcc to compile a dylib that I’m going to redistribute. For various reasons I’m using some libraries, let’s say libz to keep it simple.

Since this library is not typically found on a Mac system I wish to static link in used symbols into the dylib by passing the path to the .a-file to simplify deployment.

Now, the linker links in all symbols from the lib into the resulting dylib although I only reference a subset. On linux I’ve never encountered this problem, the linker happily discards all unreferenced symbols and creates a very slim executable, so it should be possible. The dylib file I have now is ~10 times larger than it should.

I’ve tried fiddle around with the -dead_code linker flag, but to no avail. Perhaps I just don’t understand it?

Does anyone know the solution to this?

  • 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-21T07:52:14+00:00Added an answer on May 21, 2026 at 7:52 am

    Try -Wl,--gc-sections.

    As regards -dead_strip (what you probably meant by -dead_code):

    Before turning on the -dead_strip
    option your project will first have to
    be “ported” to work with dead code
    stripping. This will include changing
    from -gused (the default for -g) to
    -gfull and re-compiling all of the objects files being linked into your
    program with the new compiler from the
    Mac OS X June 2004 release. Also if
    your building an executable that loads
    plugins, which uses symbols from the
    executable, you will have to make sure
    the symbols the plugins use are not
    stripped (by using
    attribute((used)) or the -exported_symbols_list option). If you are using an export list and building
    a shared library, or an executable
    that will be used with ld(1)’s
    -bundle_loader flag, you need to include the symbols for exception
    frame information in the export list
    for your exported C++ symbols. These
    symbols end with .eh and can be seen
    with the nm(1) tool.

    and:

    To enable dead-code stripping from the
    command line, pass the -dead_strip
    option to ld. You should also pass the
    -gfull option to GCC to generate a complete set of debugging symbols for
    your code. The linker uses this extra
    debugging information to dead strip
    the executable.

    Hope this helps.

    All content in this answer was located within the first few Google search results for “apple ld static link unused symbols”. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.