Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I compile a project with multiple source files?

I have a main code (.cpp) and some other files (.cpp and their corresponding .h file) which contain the function that are used in my main program. I'd like to know how to compile my files and run the main code.

like image 642
Sohrab Avatar asked Dec 13 '22 07:12

Sohrab


1 Answers

This depends on your compiler. For example, with GCC you might write:

g++ foo.cpp bar.cpp baz.cpp -o foo # compile program
./foo                              # run program
like image 56
ruakh Avatar answered Jan 12 '23 06:01

ruakh