eins6180
eins6180

Reputation: 163

How to link a lot of C++ object files without using too much memory?

I am writing a C++ program that uses a lot of data internally. This data is distributed over roughly 5000 source code files. When I run make, all these files compile to object code flawlessly. However, when I want to link everything together into one executable my computer runs out of memory.

Any hints are greatly appreciated.

Upvotes: 0

Views: 293

Answers (1)

Amer Agovic
Amer Agovic

Reputation: 410

Compile your code into a static library. Then compile against the library which should include only what you need in the final executable.

If you are working with GCC take a look at the AR options. Static library is an archive which you can combine and extract as needed.

Upvotes: 2

Related Questions