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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:13:31+00:00 2026-06-14T23:13:31+00:00

I have a bunch of directories with C programs. I need to compile them

  • 0

I have a bunch of directories with C programs. I need to compile them one by one and use the result in the main Program.

So my Main program traverse in the Directory structure [I am not sure what the structure is, It may change over time] and compiles one C program at a time, use that result in some computation.

So If I write the main program in C and use nftw to traverse.

OR

Write a Shell main program.

Which appraoch is better?

  • 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-14T23:13:32+00:00Added an answer on June 14, 2026 at 11:13 pm

    I guess you use a compatible Unix/Linux/Cygwin system….

    Therefore, I would advice to use a shell solution because it is more suitable for directory processing.

    Makefile for each program

    As @Dogbert said make can be used to build several programs. Build can be performed in parallel (using the option -j). Moreover make can also take care about the dependencies.

    I do not know if you are used with Makefile syntax. Therefore I give a quick example about a program requiring three C files and one header file:

    program: file1.o file2.o file3.o
        gcc -o -o $@ $^
    
    %.o: %.c header.h
        gcc -c -o $@ $< 
    

    The following command will compile file1.c, file2.c and file3.c in parallel. Then link stage will wait for the completion of these tree compilations.

    make -j3
    

    Directory discovery

    The following command finds each Makefile and runs the make command:

    find . -name Makefile -exec make -j3 -f '{}' ';' 2>&1 | tee result.txt
    

    If you have 8 cores in your computer, you can use -j8.

    Reuse in your main program

    The build result is displayed on the shell screen and is also stored in the result.txt file.

    More information?

    I do not know what is your system, or your knowledge. Hope this can help. If you are not sure to understand some parts, please ask for more information. 😉

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

Sidebar

Related Questions

I have a directory and a bunch of sub-directories like this: - directory1 (
So I have a directory of with a bunch of sub-directories that contain .java
I have an authenticated directory in my site that has a bunch of directories
I have a bunch of directories, in each directory I have bunch of sub
I use linux, bash. I have a bunch of image files in several directories.
I have a directory structure containing a bunch of config files for an application.
I have lots of directories filled with a bunch of TeX documents. So, there's
If I have a multiprocess system that needs to process a bunch of directories,
I have a bunch of sub projects in various directories. I want to specify
I have a bunch of external dlls I use in multiple projects. These dlls

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.