Building the executable

You now have all the object files needed for your project, so the next task is to link them together. To do this, add the following line to the top of the makefile:

    time_test.exe : main.obj name.obj time.obj utils.obj         link /out:$@ $**

The target here is the executable, and the dependents are the four object files. The command to build the executable calls the link tool and uses a special syntax. The $@ symbol is interpreted by the make tool as use the target, and so the /out switch will actually be /out:time_test.out. The $** symbol is interpreted by the make tool as use all the dependencies so that all the dependencies are linked.

Save this file and run the make utility. You should find that only the link tool ...

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.