User Tools

Site Tools


software_carpentary2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
software_carpentary2 [2011/06/20 04:01]
medhamsh
software_carpentary2 [2011/06/20 04:17]
medhamsh
Line 210: Line 210:
 fclose(fp); fclose(fp);
 } }
 +</​code>​
 +
 +====== Make: Automated Builds ======
 +
 +The make utility
 +
 +If you run
 +
 +<​code>​
 +make
 +</​code>​
 +
 +this program will look for a file named makefile in your directory, and then execute it.
 +If you have several makefiles, then you can execute them with the command:
 +
 +<​code>​
 +make -f MyMakefile
 +</​code>​
 +
 +There are several other switches to the make utility. For more info, man make.
 +
 +===== Build Process =====
 +
 +
 +   1. Compiler takes the source files and outputs object files
 +   2. Linker takes the object files and creates an executable
 +
 +==== Compiling by hand ====
 +
 +
 +The trivial way to compile the files and obtain an executable, is by running the command:
 +<​code>​
 +g++ main.cpp hello.cpp factorial.cpp -o hello
 +</​code>​
 +
 +==== The basic Makefile ====
 +
 +
 +The basic makefile is composed of:
 +
 +<​code>​
 +target: dependencies
 +[tab] system command
 +</​code>​
 +
 +This syntax applied to our example would look like:
 +
 +<​code>​
 +all:
 + g++ main.cpp hello.cpp factorial.cpp -o hello
 </​code>​ </​code>​
software_carpentary2.txt ยท Last modified: 2018/03/24 11:13 (external edit)