1.7. Building a Simple “Hello, World” Application Using Boost.Build
Problem
You want to use Boost.Build to build a simple “Hello, World” program, such as the one in Example 1-4.
Solution
Create a text file named Jamroot in the directory
where you wish the executable and any accompanying intermediate files to be created. In
the file Jamroot, invoke two rules, as follows. First, invoke the exe rule to declare an executable
target, specifying your .cpp file as a source. Next, invoke the install rule, specifying the executable target name and the location where
you want the install directory. Finally, run bjam to
build your program.
For example, to build an executable hello or hello.exe from the file hello.cpp in Example 1-1, create a file named Jamroot with the following content in the directory containing hello.cpp, as shown in Example 1-8.
Example 1-8. Jamfile for project hello
# jamfile for project hello exe hello : hello.cpp ; install dist : hello : <location>. ;
Next, change to the directory containing hello.cpp and Jamroot and enter the following command:
> bjam helloThis command builds the executable hello or hello.exe in a subdirectory of the current directory. Finally, enter the command:
> bjam distThis command copies the executable to the directory specified by the location property, which in this case is the current
directory.
Tip
As this book goes to press, the Boost.Build developers are preparing for the official release of Boost.Build version 2. By the time you read this, Version ...