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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:17:43+00:00 2026-05-27T07:17:43+00:00

Say your program is composed of two source files (main.c and auxiliary.c) and two

  • 0

Say your program is composed of two source files (main.c and auxiliary.c) and two header files (declarations.h and auxiliary.h).

Then you run the compiler as follows:

$gcc main.c auxiliary.c -o myprogram

Question 1: Will the compiler create one single object file for my program (i.e., just the libraries are missing) or will it create two object files, one for each source file (and then link everything together)?

Question 2: Is there ever the need to call the linker separately? Because if you use the command above the compiler will take care of that for you, right?

Question 3: Why some libraries get linked automatically (e.g., stdio) and why some require extra work (e.g., math.h requires adding a -lm when compiling). What does the -lm stand for?

Question 4: Suppose you have a single source file and your program doesn’t need any external library. Does this mean that the object code you would get from the compiler would be executable already? (i.e., compiling it like $gcc -c main.c).

  • 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-27T07:17:44+00:00Added an answer on May 27, 2026 at 7:17 am
    1. gcc creates one object file per source file, then links them to build the executable.

    2. Your example proves that gcc is able to chain all needed steps

    3. The library that gets automatically linked is the standard C library. The others need to be specified. This allows to build a smaller executable when you don’t need atan2().

      -lm indicates to the compiler that it should find the math library, whose id is m. On Unix, its filename is libm.so or libm.a depending whether the link is dynamic (performed at runtime and leading to a smaller executable) or static (performed at link time and leading to a standalone executable).

    4. No. It must be linked to the standard C library anyway. Moreover, the file format of an object code is different than an executable.

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

Sidebar

Related Questions

Suppose your program needs to keep track of, say, months of the year. Each
Let's say at your job your boss says, That system over there, which has
Say a user registers for your site, you hash the password they have chosen
Say you have a one to one relationship in your entity model. The code
let's say that you in your new programming work your boss comes and says
Let's say you have a table for branches in your organization. Some of them
Which is your preference? Let's say we have a generic Product table that has
Let's say you don't want other sites to frame your site in an <iframe>
Say, You have an application which lists down users in your application. Ideally, if
Say, you are submitting a form, which affects your database (adding records/ deleting them/

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.