简体   繁体   中英

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.

  • How can I split this task into smaller ones? Is it, for example, possible to link a subset of the object files into another object file and therefore reduce the number of object files that need to be linked in the end?
  • Where can I learn on how to set up a compilation process of very large projects?

Any hints are greatly appreciated.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM