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

  • SEARCH
  • Home
  • 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 8775409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:47:32+00:00 2026-06-13T18:47:32+00:00

When I try to compile static, I am getting the following error: gcc defrag.c

  • 0

When I try to compile static, I am getting the following error:

gcc  defrag.c -o abc.exe --static
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status

However, the same thing compiles fine without static:

gcc  defrag.c -o abc.exe 

Question: Why did the compilation failed when static is specified?

  • 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-06-13T18:47:33+00:00Added an answer on June 13, 2026 at 6:47 pm

    The error is occurring becuase “–static” says that all subsequent libraries in your link command must be static … but you only have a dynamic libc on your system.

    Recommended solution:

    gcc defrag.c -o abc -lc –static -lmystaticlib

    If you’re just trying to create a static exe for the sake of having a static exe – I’d recommend “don’t”. Shared libraries are Good. For many different reasons.

    Here’s a good link:

    • Linux static linking is dead?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try compile I'm getting the error: cannot make a static reference to
I am getting a cannot be resolved error when I try to do this:
I am getting the error message below when I try to compile my code
When I try to compile this: public static Rand searchCount (int[] x) { int
When i try to compile this: public static int compareCardhl (Card c1, Card c2)
When I try to compile this: import java.awt.* ; class obj { public static
When I try compile with maven 3.0.4, Eclipse give me this error: Failed to
When I try to compile my program on ubuntu using gcc, i get these
I am trying to compile the following code: public static void RequireOrPermanentRedirect<T>(this System.Web.UI.Page page,
Try to compile the following code in JDK7: import java.nio.file.*; public final class _DiamondSyntaxErrors

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.