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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:05:57+00:00 2026-05-15T17:05:57+00:00

I had to modify some open source code to use in a C project.

  • 0

I had to modify some open source code to use in a C project. Instead of building a library from the modified code, I’d like to just compile and build an executable from my own source combined with the modified open source code. The goal is to have a stand-alone package that can be distributed. I can get this to work just fine using the GNU build tools and have successfully built my executable.

Now I’d like to pare down the amount of code I am building and linking. Is there an easy way to determine which of the open source files I actually need to compile? There are, say, 40 .c files in the open source package. I’m guessing my code only uses (or causes to be used) 20-ish of those files. Currently I’m compiling all of them and throwing everything at the linker. There has to be a smart (and easy?) way to determine which ones I actually need, right?

I’m happy to provide further details if it’s helpful. Thanks in advance.

  • 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-15T17:05:57+00:00Added an answer on May 15, 2026 at 5:05 pm

    When faced with this I’ve either simply taken the final link command stripped out all of the objects and then added back in until it works, or processed the output of the nm command.

    Worked example:

    Looking at the output of nm:

    $ nm *.o
    
    a.o:
    00000000 T a
             U aa
    
    b.o:
    00000000 T b
    
    t.o:
             U a
             U b
    00000000 T main
    
    ua.o:
    00000000 T ua
    
    ub.o:
    00000000 T ub
    

    So I create the following awk script

    # find-unused.awk
    BEGIN {req["main"]="crt"}
    
    /\.o\:$/{
        gsub(/\:/,"");
        modulename=$0;
    }
    
    $1=="U"{
        req[$2] = modulename;
    }
    
    /[0-9,a-f].* T/{
        def[$3] = modulename;
    }
    
    END{
        print "modules referenced:"
        for (i in req)
        {
            if (def[i] != "")
                print "    "def[i];
        }
    
        print "functions not found"
        for (i in req)
        {
            if (def[i] == "")
                print "    "i;
        }
    }
    

    and then call it like this;

    $ nm *.o|awk -f find-unused.awk
    

    it tells me:

    modules referenced:
        t.o
        a.o
        b.o
    functions not found
        aa
    

    Which is right – because the ua & ub functions in the above example aren’t used.

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

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you know the location of abc.xml on your filesytem… May 16, 2026 at 2:06 pm
  • Editorial Team
    Editorial Team added an answer In your web.config: <authentication mode="Forms"> <forms name="{WhateverCookieNameYouWant}" loginUrl="LogOn.aspx" /> </authentication> May 16, 2026 at 2:06 pm
  • Editorial Team
    Editorial Team added an answer mymod and mdir.mymod are considered different modules - here's somewhat… May 16, 2026 at 2:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Note The question below was asked in 2008 about some code from 2003. As
I've recently had the need to use the managers compiler argument, because the project
I had some sample code I was working on and broke the link to
I use git for my source management, I have a local repository on my
On my previous machine I had IIS6 installed and created a web project using
FOR ANYONE INTERESTED: I have implemented the code for the behaviour I am looking
Recently I had a problem using (pipe |-) when I wanted to communicate between
What I'm trying to find out is whether there is some sort of equivalence
Had finally gotten all the bugs out of this and now they said Oh,
Had there been no System.Random class, how would have you generated a random number?

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.