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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:17:25+00:00 2026-06-03T03:17:25+00:00

Suppose one has about 50,000 different .cpp files. Each .cpp file contains just one

  • 0

Suppose one has about 50,000 different .cpp files.

Each .cpp file contains just one class that has about ~1000 lines of code in it (the code itself is not complicated — involves in-memory operations on matrices & vectors — i.e, no special libraries are used).

I need to build a project (in a Linux environment) that will have to import & use all of these 50,000 different .cpp files.

A couple of questions come to mind:

  1. How long will it roughly take to compile this? What will be the approx. size of the compiled file?
  2. What would be a better approach — keep 50,000 different .so files (compiled extenstions) and have the main program import them one by one, or alternatively, unite these 50,000 different .cpp files into one large .cpp file, and just deal with that? Which method will be faster / more efficient?

Any insights are greatly appreicated.

  • 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-03T03:17:26+00:00Added an answer on June 3, 2026 at 3:17 am

    (i) There are way too many factors involved in determining this, even an approximation is impossible. Compilation can be memory, cpu or hard drive bound. The complexity of the files matter (from your description, your complexity is low).

    (ii) The typical way of doing this is to make a library and let the system figure out linking or loading. You can choose static or dynamic linking.

    static linking
    Assuming you are using gcc, this would look like this:
    g++ -c file1.cpp -o file1.o
    g++ -c file2.cpp -o file2.o
    ...
    g++ -c filen.cpp -o filen.o
    ar -rc libvector.a file1.o file2.o ... filen.o

    Then, when you build your own code, your final link looks like this:

    g++ myfile.cpp libvector.a -o mytask

    dynamic linking
    Again, assuming you are using gcc, this would look like this:

    g++ -c file1.cpp -fPIC -o file1.o
    g++ -c file2.cpp -fPIC -o file2.o
    ...
    g++ -c filen.cpp -fPIC -o filen.o
    ld -G file1.o file2.o ... filen.o -o libvector.so

    Then, when you build your own code, your final link looks like this:

    g++ myfile.cpp libvector.so -o mytask

    You will need libvector.so to be in the loader’s path for your executable to work.

    In any case, as long as the 50,000 files don’t change, you will only need to do the last command (which will be much faster).

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

Sidebar

Related Questions

Suppose one has this code: class MyClass { public: MyClass(int foo) : foo(foo){} private:
Suppose I have two tables that are linked (one has a foreign key to
Suppose that my index has 3 fields: title, x and y. I know one
Suppose that one has some lock based code like the following where mutexes are
I'm just getting started with learning KnockoutJS. One thing that I'm confused about, the
I tried function: strstr, but it has one problem. Suppose, the URL looks like:
Suppose I have 2 models. The 2nd model has a one-to-one relationship with the
Suppose I have a class Base which has a member variable A* my_hash. I
Suppose I wish to have 2 functions, one that generates a random integer within
I need to make a design decision about database. The requirment is that one

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.