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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:29:04+00:00 2026-05-13T15:29:04+00:00

Consider the following example g++ a.o b.o c.o -o prog If it is the

  • 0

Consider the following example

g++ a.o b.o c.o -o prog

If it is the case that c.o does not contribute any executable code to prog, nor are there any dependencies on c.o in any of the other files, will GCC yet include the contents of c.o in prog?

Said another way, aside from compilation time, what (if any) negative consequences can there be of compiling unnecessary files into an executable?

Thanks in advance; Cheers!

  • 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-13T15:29:04+00:00Added an answer on May 13, 2026 at 3:29 pm

    There aren’t any negative consequences except that your executable might be unnecessarily large. The linker can probably dead strip unused code for you, and that will shrink things back down. You can use some kind of object viewing tool (otool, objdump, nm, etc.) on the output executable to see if your program has extra symbols in it.

    I’m using a Mac, so there will be some differences if you’re using the standard set of gcc tools, but here’s an example:

    $ make
    gcc -o app main.c file2.c
    gcc -Wl,-dead_strip -o app_strip main.c file2.c
    $ ls -l app*
    -rwxr-xr-x  1 carl  staff  8744 Feb  6 20:05 app
    -rwxr-xr-x  1 carl  staff  8704 Feb  6 20:05 app_strip
    

    I think in the non-Apple gcc world, you would pass -Wl,--gc-sections instead of the -Wl,-dead_strip in my example. The size difference in the two executables you can see is due to the extra function being stripped:

    $ nm app | cut -c 20- > app.txt
    $ nm app_strip | cut -c 20- > app_strip.txt 
    $ diff app.txt app_strip.txt 
    8d7
    < _function2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following example: // does not work foo( func_num_args() ); // works $args
Is there any portable way of doing branch prediction hints? Consider the following example:
Consider the following example. There is a server application that has three layers. The
Please consider the following example code (from the lm doc): ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt
Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class?
Please consider following example: The source image consists of 6 areas that need to
Consider the following example F# code: type mytype() = member this.v = new OtherClass()
Consider the following example. When I write is-a, I mean a column that is
Consider the following example (a simple 2d vector lib). Here there is a single
Consider following example code: #include <iostream> #include <inttypes.h> using namespace std; int f(uint32_t i)

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.