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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:32:41+00:00 2026-05-22T16:32:41+00:00

I want to static link libray which I included (such as stdio) with gcc,

  • 0

I want to static link libray which I included (such as stdio) with gcc, so I use the -static options.
My environment is ubuntu 10.10.
gcc version is 4.4.5.
the compile command I used is : gcc -static -o output.out input.c

the following is my source code.

include

int main(){
printf("hello world");
return 0;
}

After I compile it and use the -static option, I objdump the executable file.
and I found out that the printf is actually called _IO_printf.

And I write another program, the following is the souce code.

include

int main(){
return 0;
}

I compile this source code with the same option and objdump the new executable file.
However, I can’t find the _IO_printf.

My question is why I can’t fine _IO_printf in the second case. I have static linked the libray which I included.

Can someone plz help me solve this problem, thx.

  • 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-22T16:32:42+00:00Added an answer on May 22, 2026 at 4:32 pm

    A linker doesn’t just put object files and libraries together. It creates links between the different parts. So if there is an unresolved symbol (e.g. function or variable) in one unit, it looks for it in other units and makes the connection.

    Since the second program doesn’t call printf, the linker does not need to resolve that symbol. So there is no point adding that function to the executable (it’ll just sit there and take space). The linker can see what’s missing, and should (normally) add only what’s missing down to some practical granularity.

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

Sidebar

Related Questions

I want to use CodeDOM to both declare and initialize my static field in
I want to static link mapi32.lib with my vc++ project in vs.net2005 project. I
I want to write a (static) library for other programmers to use that uses
I want to use gcc to produce a shared library, but i want to
I've got 3 prebuilt static libraries I want to use in my shared library.
I want to initialize a static collection within my C# class - something like
I want to create a static class in PHP and have it behave like
I want to give a static javascript block of code to a html template
I want to call a few static methods of a CPP class defined in
I want to know what are static and dynamic type checking and the differences

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.