1

I want to compile all the cpp files in my current directory into their own executables with one call. None of these files share anything so they don't need to be compiled into a single program. I was thinking about using a script but then I remembered about make and makefiles (haven't used it in years). Can I write a makefile to do this?

Philip Nelson
  • 970
  • 10
  • 26

1 Answers1

0

This post answers your question. It is about C programs but you can adapt it to C++.

Makefile to compile multiple C programs?

Philip Nelson
  • 970
  • 10
  • 26
  • Thank you! This is what I was thinking to do, was just wondering if there was something cleaner. – Igor Pieters Feb 27 '20 at 17:40
  • Look at the answer that mentions [Pattern rules](https://www.gnu.org/software/make/manual/html_node/Static-Usage.html#Static-Usage). They let you compile multiple files which require the same compilation commands. Might be cleaner. – Philip Nelson Feb 27 '20 at 17:41