mirror of
https://github.com/boostorg/website-v2-docs.git
synced 2026-01-19 04:42:17 +00:00
getting started guide uses tabs
This commit is contained in:
committed by
Alan de Freitas
parent
0e96d6b068
commit
337481224a
7
.github/workflows/publish.yml
vendored
7
.github/workflows/publish.yml
vendored
@@ -20,15 +20,10 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Antora Setup
|
||||
uses: ./.github/actions/antora_publish
|
||||
with:
|
||||
setup_only: true
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
./libdoc.sh "${{ (startsWith(github.ref, 'refs/heads/develop') && 'develop') || 'master' }}"
|
||||
./sitedoc.sh "${{ (startsWith(github.ref, 'refs/heads/develop') && 'develop') || 'master' }}"
|
||||
./sitedoc.sh ${{ github.ref }}
|
||||
|
||||
- name: Remove lib dirs
|
||||
working-directory: build
|
||||
|
||||
10
antora-ui/package-lock.json
generated
10
antora-ui/package-lock.json
generated
@@ -8,6 +8,7 @@
|
||||
"license": "MPL-2.0",
|
||||
"devDependencies": {
|
||||
"@asciidoctor/core": "~2.2",
|
||||
"@asciidoctor/tabs": "^1.0.0-beta.3",
|
||||
"@fontsource/roboto": "~4.5",
|
||||
"@fontsource/roboto-mono": "~4.5",
|
||||
"autoprefixer": "~9.7",
|
||||
@@ -79,6 +80,15 @@
|
||||
"yarn": ">=1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@asciidoctor/tabs": {
|
||||
"version": "1.0.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@asciidoctor/tabs/-/tabs-1.0.0-beta.3.tgz",
|
||||
"integrity": "sha512-Cx6LQCLl703BwuejZZSwBy1s7CuJxD9AVY2mAgE0UDXfPmFsY3Il3JMGQ+1JAwHH0hd7htLEq+yG5EiiLdCJeg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
"version": "7.18.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@asciidoctor/core": "~2.2",
|
||||
"@asciidoctor/tabs": "^1.0.0-beta.3",
|
||||
"@fontsource/roboto": "~4.5",
|
||||
"@fontsource/roboto-mono": "~4.5",
|
||||
"autoprefixer": "~9.7",
|
||||
|
||||
@@ -17,6 +17,17 @@ Vis no velit audiam, sonet <<dependencies,praesent>> eum ne.
|
||||
Integer diam enim, dignissim eget eros et, ultricies mattis odio.
|
||||
--
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Tab A::
|
||||
+
|
||||
====
|
||||
Example block in Tab A.
|
||||
====
|
||||
|
||||
Tab B:: Just text.
|
||||
======
|
||||
|
||||
Vestibulum consectetur nec urna a luctus.
|
||||
Quisque pharetra tristique arcu fringilla dapibus.
|
||||
https://example.org[Curabitur,role=unresolved] ut massa aliquam, cursus enim et, accumsan lectus.
|
||||
|
||||
@@ -124,3 +124,6 @@ page:
|
||||
- content: Some Code
|
||||
url: '/xyz/5.2/index.html#some-code'
|
||||
urlType: internal
|
||||
asciidoc:
|
||||
extensions:
|
||||
- '@asciidoctor/tabs'
|
||||
|
||||
1
antora-ui/src/css/vendor/tabs.css
vendored
Normal file
1
antora-ui/src/css/vendor/tabs.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
@import "@asciidoctor/tabs";
|
||||
1
antora-ui/src/js/vendor/highlight.bundle.js
vendored
1
antora-ui/src/js/vendor/highlight.bundle.js
vendored
@@ -6,6 +6,7 @@
|
||||
hljs.registerLanguage('bash', require('highlight.js/lib/languages/bash'))
|
||||
hljs.registerLanguage('clojure', require('highlight.js/lib/languages/clojure'))
|
||||
hljs.registerLanguage('cpp', require('highlight.js/lib/languages/cpp'))
|
||||
hljs.registerLanguage('cmake', require('highlight.js/lib/languages/cmake'))
|
||||
hljs.registerLanguage('cs', require('highlight.js/lib/languages/cs'))
|
||||
hljs.registerLanguage('css', require('highlight.js/lib/languages/css'))
|
||||
hljs.registerLanguage('diff', require('highlight.js/lib/languages/diff'))
|
||||
|
||||
1
antora-ui/src/js/vendor/tabs.bundle.js
vendored
Normal file
1
antora-ui/src/js/vendor/tabs.bundle.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
require('@asciidoctor/tabs')
|
||||
@@ -3,3 +3,5 @@
|
||||
{{#if env.SITE_SEARCH_PROVIDER}}
|
||||
{{> search-scripts}}
|
||||
{{/if}}
|
||||
<script async src="{{{uiRootPath}}}/js/vendor/tabs.js" data-sync-storage-key="preferred-tab"></script>
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
<link rel="stylesheet" href="{{{uiRootPath}}}/css/site.css">
|
||||
<link rel="stylesheet" href="{{{uiRootPath}}}/css/vendor/tabs.css">
|
||||
|
||||
@@ -71,7 +71,8 @@ module.exports = function (registry) {
|
||||
const self = this;
|
||||
self.process(function (parent, target, attr) {
|
||||
let title = attr.$positional ? attr.$positional[0] : `Boost.${toPascalCase(target)}`;
|
||||
let text = `https://www.boost.org/libs/${toSnakeCase(target)}[${title}]`;
|
||||
let is_tool = ['auto_index', 'bcp', 'boostbook', 'boostdep', 'boost_install', 'build', 'check_build', 'cmake', 'docca', 'inspect', 'litre', 'quickbook'].includes(toSnakeCase(target));
|
||||
let text = `https://www.boost.org/${is_tool ? 'tools' : 'libs'}/${toSnakeCase(target)}[${title}]`;
|
||||
return self.createInline(parent, 'quoted', text);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,6 +42,7 @@ asciidoc:
|
||||
page-commit-id: ''
|
||||
extensions:
|
||||
- ./extensions/boost-link-inline-macro.js
|
||||
- '@asciidoctor/tabs'
|
||||
|
||||
content:
|
||||
sources:
|
||||
|
||||
9
package-lock.json
generated
9
package-lock.json
generated
@@ -6,6 +6,7 @@
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@antora/lunr-extension": "^1.0.0-alpha.8",
|
||||
"@asciidoctor/tabs": "^1.0.0-beta.3",
|
||||
"process": "^0.11.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -304,6 +305,14 @@
|
||||
"yarn": ">=1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@asciidoctor/tabs": {
|
||||
"version": "1.0.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@asciidoctor/tabs/-/tabs-1.0.0-beta.3.tgz",
|
||||
"integrity": "sha512-Cx6LQCLl703BwuejZZSwBy1s7CuJxD9AVY2mAgE0UDXfPmFsY3Il3JMGQ+1JAwHH0hd7htLEq+yG5EiiLdCJeg==",
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@iarna/toml": {
|
||||
"version": "2.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@antora/lunr-extension": "^1.0.0-alpha.8",
|
||||
"@asciidoctor/tabs": "^1.0.0-beta.3",
|
||||
"process": "^0.11.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ antora:
|
||||
asciidoc:
|
||||
extensions:
|
||||
- ./extensions/boost-link-inline-macro.js
|
||||
- '@asciidoctor/tabs'
|
||||
|
||||
content:
|
||||
sources:
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
* xref:intro.adoc[Introduction to Boost]
|
||||
* xref:getting-started-with-windows.adoc[]
|
||||
* xref:getting-started-with-linux.adoc[]
|
||||
* xref:getting-started-with-macos.adoc[]
|
||||
* xref:use-boost-with-windows-package-manager.adoc[]
|
||||
* xref:use-boost-with-linux-package-manager.adoc[]
|
||||
* xref:getting-started.adoc[]
|
||||
* xref:boost-history.adoc[]
|
||||
|
||||
* Reference
|
||||
|
||||
@@ -5,7 +5,7 @@ This topic aims to provide an overview of the origins, growth, and impact of the
|
||||
|
||||
== Introduction
|
||||
|
||||
The Boost pass:[C++] Library is a highly influential and widely used collection of libraries, designed to extend and complement the functionality provided by the pass:[C++] Standard Library. Since its original https://www.boost.org/users/proposal.pdf[Proposal] in 1998, the Boost pass:[C++] Library has played a significant role in shaping the evolution of the pass:[C++] language and its ecosystem.
|
||||
The Boost pass:[C++] Library is a highly influential and widely used collection of libraries, designed to extend and complement the functionality provided by the pass:[C++] Standard Library. Since its original https://www.boost.org/users/proposal.pdf[Proposal] in 1998, the Boost pass:[C++] Library has played a significant role in shaping the evolution of the pass:[C++] language and its ecosystem.
|
||||
|
||||
== Origins
|
||||
|
||||
@@ -72,4 +72,4 @@ _The best software solutions are written using the C++ programming language_
|
||||
- https://github.com/boostorg/website/blob/master/development/report-may-2008.rst[Review Wizard Status Report for May 2008]
|
||||
- https://github.com/boostorg/website/blob/master/development/report-nov-2008.rst[Review Wizard Status Report for November 2008]
|
||||
- https://github.com/boostorg/website/blob/master/development/report-jun-2009.rst[Review Wizard Status Report for June 2009]
|
||||
- https://github.com/boostorg/website/blob/master/development/report-dec-2009.rst[Review Wizard Status Report for December 2009]
|
||||
- https://github.com/boostorg/website/blob/master/development/report-dec-2009.rst[Review Wizard Status Report for December 2009]
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
= Getting Started with Linux
|
||||
:navtitle: Getting Started Linux
|
||||
|
||||
To install the Boost libraries on a Linux system, you can either use the package manager provided by your distribution or compile and install Boost from the source code. Here's a step-by-step guide for installing from source.
|
||||
|
||||
If you are used to working with a package manager, refer to xref:use-boost-with-linux-package-manager.adoc[Use Boost with Linux and a Package Manager].
|
||||
|
||||
== Installing from Source
|
||||
|
||||
. Open a terminal window.
|
||||
|
||||
. Install the necessary build tools and libraries. For Ubuntu or Debian-based distributions, use the following commands:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo apt update
|
||||
sudo apt install build-essential python3 libbz2-dev libz-dev libicu-dev
|
||||
----
|
||||
+
|
||||
For Fedora systems, use the following commands:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo dnf update
|
||||
sudo dnf install gcc-c++ python3 bzip2-devel zlib-devel libicu-devel
|
||||
----
|
||||
+
|
||||
For CentOS systems, use the following commands:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo yum update
|
||||
sudo yum install gcc-c++ python3 bzip2-devel zlib-devel libicu-devel
|
||||
----
|
||||
+
|
||||
For Arch-based systems (Arch Linux, Manjaro, etc.), use the following commands:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo pacman -Syu
|
||||
sudo pacman -S base-devel python3 bzip2 zlib icu
|
||||
----
|
||||
|
||||
|
||||
. Download the latest Boost source code from the official website (https://www.boost.org/users/download/), or use `wget` to download it directly:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
wget https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.bz2
|
||||
----
|
||||
|
||||
+
|
||||
*Replace the URL and version number (1.82.0) with the latest version available.*
|
||||
|
||||
. Extract the downloaded archive:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
tar xvfj boost_1_82_0.tar.bz2
|
||||
----
|
||||
|
||||
. Change to the extracted directory:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
cd boost_1_82_0
|
||||
----
|
||||
|
||||
. Run the bootstrap script to prepare for building Boost:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
./bootstrap.sh --prefix=/usr/local
|
||||
----
|
||||
+
|
||||
The --prefix option specifies the installation directory. You can change this to your preferred location.
|
||||
|
||||
. Build and install Boost: `sudo ./b2 install`. This command builds and installs the Boost libraries to the specified prefix directory.
|
||||
|
||||
. (Optional) To use the installed Boost libraries, you may need to update your environment variables:
|
||||
+
|
||||
For LD_LIBRARY_PATH:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
|
||||
----
|
||||
+
|
||||
For CPLUS_INCLUDE_PATH:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH
|
||||
----
|
||||
+
|
||||
Replace `/usr/local` with the prefix directory you specified during the installation, if different.
|
||||
+
|
||||
You can add these `export` commands to your `~/.bashrc` or `~/.profile` file to make the changes permanent.
|
||||
|
||||
After completing either method, you should have the Boost libraries installed on your Linux system.
|
||||
|
||||
[#your-first-app]
|
||||
== Your First App
|
||||
|
||||
To keep things simple, let’s start by using a header-only library. The following program reads a sequence of integers from standard input, uses Boost.Lambda to multiply each number by three, and writes them to standard output:
|
||||
|
||||
. Copy the following program into a file called *example.cpp*.
|
||||
+
|
||||
[source,C++]
|
||||
----
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::lambda;
|
||||
typedef std::istream_iterator<int> in;
|
||||
|
||||
std::for_each(
|
||||
in(std::cin), in(), std::cout << (_1 * 3) << " ");
|
||||
}
|
||||
----
|
||||
|
||||
. Now, in the directory where you saved *example.cpp*, issue the following command (replacing _1_82_0_ with the Boost version number you are using):
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
c++ -I path/to/boost_1_82_0 example.cpp -o example
|
||||
----
|
||||
|
||||
. To test the result, type:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
echo 1 2 3 | ./example
|
||||
----
|
||||
|
||||
. Did you get the expected result?
|
||||
|
||||
== Create and Run a GitHub Example App
|
||||
|
||||
In this section, we will locate an example from a folder on GitHub, and then build and run a project based on the example.
|
||||
|
||||
For most Boost libraries, there is an *example* subfolder containing a range of runnable examples. For this guide, we will locate an example that reads a JSON file, and pretty-prints the contents.
|
||||
|
||||
. Copy all the code from https://github.com/boostorg/json/blob/develop/example/pretty.cpp, and use it to replace all the default content of the project's cpp file.
|
||||
|
||||
. Add to your project a file called *file.hpp*, then copy all the content from https://github.com/boostorg/json/blob/develop/example/file.hpp into that file.
|
||||
|
||||
. Search your computer for any JSON file, unless you have one you would like to use already. Record the full path to that file.
|
||||
@@ -1,87 +0,0 @@
|
||||
= Getting Started with macOS
|
||||
:navtitle: Getting Started macOS
|
||||
|
||||
To install and build Boost libraries on macOS, you can either use CMake, or install and use a package manager such as Homebrew, a popular package manager for macOS that simplifies the installation of software packages.
|
||||
|
||||
== Install Boost using CMake
|
||||
|
||||
If you do not wish to use a package manager, installing Boost libraries on macOS using CMake involves several steps. Here's an outline of the process:
|
||||
|
||||
. Open a terminal window and navigate to the directory where you extracted the Boost library files.
|
||||
|
||||
. Run the bootstrap.sh script to generate the build system files for your platform. For example, to build Boost with clang on macOS, run:
|
||||
|
||||
[source,txt]
|
||||
----
|
||||
./bootstrap.sh toolset=clang
|
||||
----
|
||||
|
||||
. After the bootstrap process completes, run the following command to build and install the Boost libraries: .`/b2 install`.
|
||||
|
||||
. Once the Boost libraries are installed, you can use CMake to configure your project to use them. Here's an example CMakeLists.txt file that uses Boost:
|
||||
|
||||
[source, cmake]
|
||||
----
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(MyProject)
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS system)
|
||||
|
||||
add_executable(MyProject main.cpp)
|
||||
|
||||
target_link_libraries(MyProject Boost::system)
|
||||
----
|
||||
|
||||
. This CMakeLists.txt file assumes that your main.cpp file uses the Boost system library. You may need to modify it to use other Boost libraries depending on your project's requirements.
|
||||
|
||||
. Run CMake to generate the build system files for your project: `cmake .`
|
||||
|
||||
. After the CMake configuration process completes, you can build your project using your preferred build system (e.g. make, ninja, etc.): `make`.
|
||||
|
||||
== Install Boost using Homebrew
|
||||
|
||||
Here's a step-by-step guide to installing the Boost libraries using Homebrew.
|
||||
|
||||
=== Prerequisites
|
||||
|
||||
Homebrew has a few prerequisites, one of which is the Xcode Command Line Tools. The Xcode Command Line Tools include essential developer tools, like compilers and build utilities, that Homebrew needs to function properly.
|
||||
|
||||
When you install Homebrew using the installation script, it will automatically check for the presence of the Xcode Command Line Tools. If they are not already installed, the script will prompt you to install them.
|
||||
|
||||
However, if you want to manually install the Xcode Command Line Tools before installing Homebrew, you can follow these steps:
|
||||
|
||||
. Open Terminal.
|
||||
|
||||
. Run the following command: `xcode-select --install`. A pop-up window will appear, prompting you to install the Xcode Command Line Tools. Click *Install* to start the installation process.
|
||||
|
||||
Once the Xcode Command Line Tools are installed, you can proceed with installing Homebrew.
|
||||
|
||||
It's important to note that the full Xcode application is not required to use Homebrew, but it can be beneficial for developers who need additional development tools or want to create macOS and iOS applications. You can download and install the full Xcode application from the Mac App Store if you need it.
|
||||
|
||||
=== Install Homebrew
|
||||
|
||||
You can skip step 1 if you have already installed Homebrew.
|
||||
|
||||
. Open Terminal and run the following command:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
----
|
||||
+
|
||||
This command will download and execute the Homebrew installation script. Follow the prompts to complete the installation.
|
||||
|
||||
. Update Homebrew. Before installing the Boost libraries, it's a good idea to update Homebrew to ensure you have the latest package information. Run the following commands: `brew update` followed by `brew upgrade` if there are outdated formulae.
|
||||
|
||||
=== Install Boost
|
||||
|
||||
. Now you can install the Boost libraries using Homebrew. Run the following command: `brew install boost`. Homebrew will download and install the Boost libraries and their dependencies.
|
||||
|
||||
. To verify that the Boost libraries are installed correctly, you can run the following command: `brew list boost`. This command will show the installed files for the Boost libraries.
|
||||
|
||||
Now the Boost libraries are installed on your macOS system, and you can use them in your projects.
|
||||
|
||||
To use Boost in your projects, you may need to configure your build system (e.g., CMake, Makefile, Xcode) to include the appropriate header files and link against the Boost libraries. The specific configuration depends on the build system and the Boost libraries you're using.
|
||||
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
= Getting Started with Windows
|
||||
:navtitle: Getting Started Windows
|
||||
|
||||
This section explains how to get your first Boost app running on Windows. The entire set of libraries is installed, which gives you the chance to explore the features and functionality available.
|
||||
|
||||
== Prerequisites
|
||||
|
||||
[circle]
|
||||
* Microsoft Visual Studio 2022 (Community Edition) is used as the IDE and C++ compiler in the examples (https://visualstudio.microsoft.com/downloads/). If you are using a different system, you will need to investigate and adjust the steps accordingly.
|
||||
|
||||
* The Boost library is currently just under 200 MB. Make sure you have ample disk space to download and extract the full library. Downloading and installing specific libraries is explained in the "Getting Started with Windows and a Package Manager".
|
||||
|
||||
== Download and Extract the Full Boost Library Package
|
||||
|
||||
To install the full set of Boost libraries on Windows:
|
||||
|
||||
. Navigate to https://www.boost.org/users/download/.
|
||||
|
||||
. Under *Current Release/Downloads*, click the Windows .zip option.
|
||||
|
||||
. After the download has completed (in your *Downloads* folder), right-click on the zip file and extract it to a folder. It does not matter where you extract it to, but consider extracting it to your *Documents* folder, just so that it is easy to locate from a Command Prompt.
|
||||
|
||||
NOTE: Extracting the zip takes some time. If you have a .7z extractor application, you can download the .7z version. This uses less space, and extracts quicker, than the .zip alternative. Refer to https://7-zip.org/.
|
||||
|
||||
== Bootstrap the Boost Build App
|
||||
|
||||
. Open up a command line terminal, and navigate to the folder containing the *bootstrap.bat* file. If you used the folder location specified above, this would mean entering `cd documents\boost-libraries`.
|
||||
|
||||
. The Boost libraries are built using a custom build app called *b2.exe*. This app itself is built by running `.\bootstrap.bat` in your Command Prompt.
|
||||
|
||||
NOTE:: You do not need read the build documentation to complete this guide, however, for more information, refer to the https://www.boost.org/doc/libs/1_81_0/tools/build/doc/html/index.html[B2 User Manual].
|
||||
|
||||
== Build and Install the Boost Libraries
|
||||
|
||||
Building and installing Boost libraries also takes some time.
|
||||
|
||||
. Decide where you are going to install the libraries to, most locations are OK, something like *Documents/Boost-libraries* is fine. If your location has a space in the name, you will need to surround the path in quotes in the commands that follow.
|
||||
|
||||
. In the older now containing the *b2.exe* app, run the app by entering `.\b2.exe` in the Command Prompt. This builds the libraries, but does not yet install them. Refer to <<Troubleshooting the Build and Install Process>>, if you get any errors.
|
||||
|
||||
. Now enter `.\b2.exe --prefix=<YOUR-INSTALL-FOLDER> -d0 install`. This installs the libraries to your selected folder. The option `-d0` suppresses most of the command line warnings and messages.
|
||||
|
||||
NOTE:: We break the build and install into separate steps, in order to get better diagnostics when building the libraries, and to suppress too many messages when installing the libraries. The single command `.\b2.exe --prefix=<YOUR-INSTALL-FOLDER> -d0 install` will both build and install, but suppresses too many messages during the build process. If something goes wrong, it will probably be during the build process, and we want to know about it.
|
||||
|
||||
. The build process creates all variants of each library. For example, there may be _Release_ and _Debug_ variants, or possibly _Multithreaded_ and _Static_ runtime variants. Also, libraries that are _header-only_ (in other words, do not require being built) are copied to your installation folder. Quickly examine your installation folder to see that it is well populated, or enter `.\b2.exe --show libraries` in your Command Prompt.
|
||||
|
||||
=== Troubleshooting the Build and Install Process
|
||||
|
||||
* If you get an error during the build process such as the following, you probably do not have an up to date and full installation of C++ on your machine. Go back to <<Prerequisites>> and install or update your version of Visual Studio.
|
||||
|
||||
image::cpp-runtime-error.png[]
|
||||
|
||||
== Create and Run a "Hello World" App
|
||||
|
||||
. Open Visual Studio and select *Create a new project*. Choose *Console App* from the range of project templates.
|
||||
|
||||
. Change the names in the *Configure your new project* dialog, or leave the defaults, and click *Create*.
|
||||
|
||||
. Replace all the boilerplate content of the .cpp file with the following, noting the inclusion of the compiled header from Boost: *lambda.hpp*:
|
||||
|
||||
+
|
||||
[source,C++]
|
||||
----
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::lambda;
|
||||
typedef std::istream_iterator<int> in;
|
||||
|
||||
std::for_each(
|
||||
in(std::cin), in(), std::cout << (_1 * 3) << " ");
|
||||
}
|
||||
----
|
||||
|
||||
. Right-click on the name of the project in the *Solution Explorer* pane, and select *Properties*.
|
||||
|
||||
. Under *C/C++* select *General*, then click on *Additional Include Directories*. Add the path to your Boost *include* folder, that will have been built in the previous section.
|
||||
|
||||
image::additional-include-directories.png[]
|
||||
|
||||
. Next, still in the project properties, select *Linker*, then *General*, and locate the *Additional Library Directories*. Add the path to the Boost *lib* folder.
|
||||
|
||||
image::additional-library-directories.png[]
|
||||
|
||||
. Click *OK* to accept your input, and then in the *Debug* menu, select *Start Without Debugging*, or press the F5 key.
|
||||
|
||||
. A Command Prompt should open up, so enter a list of numbers separated by spaces, and then *Enter*.
|
||||
|
||||
. You should get a line of numbers, your originals multiplied by 3.
|
||||
|
||||
image:first-app-running.png[]
|
||||
|
||||
== Create and Run a GitHub Example App
|
||||
|
||||
In this section, we will locate an example from a folder on GitHub, and then build and run a project based on the example.
|
||||
|
||||
For most Boost libraries, there is an *example* subfolder containing a range of runnable examples. For this guide, we will locate an example that reads a JSON file, and pretty-prints the contents.
|
||||
|
||||
. Create a new Visual Studio C++ Console App. Name it JsonPrint.
|
||||
|
||||
. Update both the additional include directories, and additional library directories, as you did for the previous section.
|
||||
|
||||
. Copy all the code from https://github.com/boostorg/json/blob/develop/example/pretty.cpp, and use it to replace all the default content of the project's cpp file.
|
||||
|
||||
. Add to your project a file called *file.hpp*, then copy all the content from https://github.com/boostorg/json/blob/develop/example/file.hpp into that file.
|
||||
|
||||
. Search your computer for any JSON file, unless you have one you would like to use already. Record the full path to that file.
|
||||
|
||||
. In Visual Studio, locate and select *Build Solution*.
|
||||
|
||||
. In a Command Prompt, navigate to where the .exe file for the solution has been built. This will often be `C:\Users\YOUR NAME\source\repos\JsonPrint\x64\Debug`.
|
||||
|
||||
. In the Command Prompt, type `JsonPrint PATH`, where PATH is the full path to your JSON file, including the filename. You should get neatly formatted output:
|
||||
|
||||
image:json-example-running.png[]
|
||||
|
||||
=== Troubleshooting Create and Run a GitHub Example App
|
||||
|
||||
[circle]
|
||||
* If your JSON included symbols such as the umlaut, these will not be rendered correctly unless you change the format of your Command Prompt to UTF-8. By default, a Command Prompt supports a code page numbered 437. To change the code page to UTF-8, type `chcp 65001`.
|
||||
|
||||
* If you get compile errors such as `cannot open file 'libboost_json-vc143-mt-gd-x64-1_81.lib'` you have probably not entered the *Additional Library Directories* correctly.
|
||||
|
||||
== Summary
|
||||
|
||||
Although the samples you have now built and run are quite simple, if you have got this far successfully, it means your build and installation and project linking are all working correctly. Great job!
|
||||
|
||||
== Next Steps
|
||||
|
||||
You might like to scan the examples folders of some of the other libraries that you are interested in, and create and run projects to get them running.
|
||||
|
||||
Once you are more experienced with Boost, you might like to build and install only those libraries you require. This process is best managed by a _Package Manager_.
|
||||
|
||||
[square]
|
||||
* xref:use-boost-with-windows-package-manager.adoc[Use Boost with Windows and a Package Manager]
|
||||
865
user-guide/modules/ROOT/pages/getting-started.adoc
Normal file
865
user-guide/modules/ROOT/pages/getting-started.adoc
Normal file
@@ -0,0 +1,865 @@
|
||||
= Getting Started
|
||||
:navtitle: Getting Started
|
||||
:latest_tag: 1_82_0
|
||||
:latest_version: 1.82.0
|
||||
:release_basename: boost_{latest_tag}
|
||||
:release_filename: {release_basename}.tar.bz2
|
||||
:release_zip_filename: {release_basename}.zip
|
||||
:release_url: https://boostorg.jfrog.io/artifactory/main/release/{latest_version}/source/{release_filename}
|
||||
:release_zip_url: https://boostorg.jfrog.io/artifactory/main/release/{latest_version}/source/{release_zip_filename}
|
||||
:linkattrs:
|
||||
|
||||
This section explains how to get your first Boost app running.
|
||||
Here's a step-by-step guide for installing from source.
|
||||
|
||||
== Prerequisites
|
||||
|
||||
The only prerequisite for installing boost is a pass:[C++] compiler.
|
||||
If you already have that set-up, please skip to the xref:#installing[] section.
|
||||
|
||||
If you don't have access to a pass:[C++] compiler yet, here are a few ways to get started:
|
||||
|
||||
:tabs-sync-option:
|
||||
|
||||
[tabs,sync-group-id=os]
|
||||
====
|
||||
Windows::
|
||||
+
|
||||
--
|
||||
Users on Windows usually get started with the Visual Studio compiler.
|
||||
You can download the https://visualstudio.microsoft.com/downloads/[Microsoft Visual Studio 2022] (Community Edition) as the IDE and pass:[C++] compiler in these examples.
|
||||
--
|
||||
|
||||
Linux::
|
||||
+
|
||||
--
|
||||
Users on Linux usually get started with GCC.
|
||||
You can check if GCC is already installed with:
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
g++ --version
|
||||
----
|
||||
|
||||
Otherwise, you need to install the necessary build tools and libraries.
|
||||
For Ubuntu or Debian-based distributions, use the following commands:
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
sudo apt update
|
||||
sudo apt install build-essential python3 libbz2-dev libz-dev libicu-dev
|
||||
----
|
||||
|
||||
For Fedora systems, use the following commands:
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
sudo dnf update
|
||||
sudo dnf install gcc-c++ python3 bzip2-devel zlib-devel libicu-devel
|
||||
----
|
||||
|
||||
For CentOS systems, use the following commands:
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
sudo yum update
|
||||
sudo yum install gcc-c++ python3 bzip2-devel zlib-devel libicu-devel
|
||||
----
|
||||
|
||||
For Arch-based systems (Arch Linux, Manjaro, etc.), use the following commands:
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
sudo pacman -Syu
|
||||
sudo pacman -S base-devel python3 bzip2 zlib icu
|
||||
----
|
||||
--
|
||||
|
||||
macOS::
|
||||
+
|
||||
--
|
||||
Users on macOS usually get started with Clang.
|
||||
You can check if Clang is already installed with:
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
clang++ --version
|
||||
----
|
||||
--
|
||||
====
|
||||
|
||||
[#installing]
|
||||
== Installing
|
||||
|
||||
=== Download Boost
|
||||
|
||||
[tabs,sync-group-id=build]
|
||||
====
|
||||
Boost.Build::
|
||||
+
|
||||
--
|
||||
. Navigate to https://www.boost.org/users/download/ and under *Current Release/Downloads*, download the Boost distribution.
|
||||
For instance:
|
||||
.. Windows: {release_zip_url}[boost_{latest_tag}.zip]
|
||||
.. Unix variants: {release_url}[boost_{latest_tag}.tar.bz2]
|
||||
|
||||
. After the download has completed in your *Downloads* folder, right-click on the compressed file and extract it to a folder.
|
||||
|
||||
TIP: boost:build[] is the officially supported build system used by the Boost libraries.
|
||||
--
|
||||
|
||||
CMake::
|
||||
+
|
||||
--
|
||||
The Boost distribution for CMake has a different layout.
|
||||
|
||||
. Navigate to https://github.com/boostorg/boost/releases and under *Releases*, download the Boost distribution.
|
||||
For instance:
|
||||
.. Windows: https://github.com/boostorg/boost/releases/download/boost-{latest_version}/boost-{latest_version}.zip[boost-{latest_tag}.zip]
|
||||
.. Unix variants: https://github.com/boostorg/boost/releases/download/boost-{latest_version}/boost-{latest_version}.tar.gz[boost-{latest_tag}.tar.bz2]
|
||||
|
||||
. After the download has completed in your *Downloads* folder, right-click on the compressed file and extract it to a folder.
|
||||
|
||||
TIP: TIP: You don't need to *build* Boost with CMake to be able to *use* Boost with CMake.
|
||||
CMake integration will work fine even if you install Boost with boost:build[].
|
||||
--
|
||||
====
|
||||
|
||||
Or you can streamline the whole process directly from the command line:
|
||||
|
||||
[tabs,sync-group-id=os]
|
||||
====
|
||||
Windows::
|
||||
+
|
||||
--
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
curl {release_zip_url} <1>
|
||||
7z x {release_filename} <2>
|
||||
cd {release_basename} <3>
|
||||
----
|
||||
|
||||
<.> Download the boost distribution `{release_zip_filename}`
|
||||
<.> Extract the files into `{release_basename}`
|
||||
<.> Change the current working directory to `{release_basename}`
|
||||
|
||||
Note that these instructions assume you have https://curl.se/[Curl,window="_blank"] and https://www.7-zip.org/[7-Zip,window="_blank"] installed on your system.
|
||||
|
||||
--
|
||||
|
||||
Linux::
|
||||
+
|
||||
--
|
||||
[source,bash,subs="attributes+"]
|
||||
----
|
||||
wget {release_url} <1>
|
||||
tar xvfj {release_filename} <2>
|
||||
cd {release_basename} <3>
|
||||
----
|
||||
|
||||
<.> Download the boost distribution `{release_filename}`
|
||||
<.> Extract the files into `{release_basename}`
|
||||
<.> Change the current working directory to `{release_basename}`
|
||||
--
|
||||
|
||||
macOS::
|
||||
+
|
||||
--
|
||||
[source,bash,subs="attributes+"]
|
||||
----
|
||||
curl {release_url} <1>
|
||||
tar xvfj {release_filename} <2>
|
||||
cd {release_basename} <3>
|
||||
----
|
||||
|
||||
<.> Download the boost distribution `{release_filename}`
|
||||
<.> Extract the files into `{release_basename}`
|
||||
<.> Change the current working directory to `{release_basename}`
|
||||
--
|
||||
|
||||
Git::
|
||||
+
|
||||
--
|
||||
You can clone and initialize the complete Boost super-project directly from GitHub with:
|
||||
|
||||
[source,bash,subs="attributes+"]
|
||||
----
|
||||
git clone https://github.com/boostorg/boost.git -b boost-{latest_version} {release_basename} --depth 1 <1>
|
||||
cd {release_basename}
|
||||
git submodule update --depth 1 --init --recursive <2>
|
||||
----
|
||||
|
||||
<.> Clone the Boost super-project
|
||||
<.> Initialize all boost modules
|
||||
--
|
||||
====
|
||||
|
||||
=== Downloading Boost Modules
|
||||
|
||||
The process above downloads all boost libraries, which is the usual process in a local installation.
|
||||
In projects where only a subset of the Boost libraries is required, which is usually desired in Continuous Integration Systems, the following procedure can be used:
|
||||
|
||||
[source,bash,subs="attributes+"]
|
||||
.Downloading boost:unordered[] and internal dependencies
|
||||
----
|
||||
git clone https://github.com/boostorg/boost.git -b boost-{latest_version} {release_basename} --depth 1 <1>
|
||||
git submodule update --depth 1 -q --init tools/boostdep <2>
|
||||
git submodule update --depth 1 -q --init libs/unordered <3>
|
||||
python tools/boostdep/depinst/depinst.py -X test -g "--depth 1" unordered <4>
|
||||
----
|
||||
|
||||
<1> Download the Boost super-project, which contains references to all Boost libraries
|
||||
<2> Initialize boost:boostdep[] used to determine internal boost dependencies
|
||||
<3> Initialize boost:unordered[].
|
||||
Repeat this step for any other modules you need.
|
||||
<4> Initialize any dependencies of boost:unordered[].
|
||||
Repeat this step for any other modules you need.
|
||||
|
||||
This procedure requires `git` and `python`.
|
||||
The following steps in this document apply to both methods of installing Boost.
|
||||
The only difference is what libraries will be available.
|
||||
|
||||
=== Bootstrap
|
||||
|
||||
If you followed the steps above, your current working directory should be `{release_basename}`.
|
||||
Otherwise, open up a command line terminal, and navigate to the boost folder you extracted.
|
||||
|
||||
[tabs,sync-group-id=build]
|
||||
====
|
||||
Boost.Build::
|
||||
+
|
||||
--
|
||||
The Boost libraries are built using a custom build app called boost:build[].
|
||||
This app itself is built by running the bootstrap script.
|
||||
|
||||
This is the usual procedure to configure, build and install Boost with boost:build[]:
|
||||
|
||||
If your location has a space in the name, you will need to surround the path in quotes in the commands that follow.
|
||||
|
||||
Windows:
|
||||
|
||||
[source]
|
||||
----
|
||||
bootstrap.bat
|
||||
b2
|
||||
b2 install --prefix=C:\Boost
|
||||
----
|
||||
|
||||
If you get an error during the build process such as the following, you probably do not have an up to date and full installation of pass:[C++] on your machine.
|
||||
Go back to <<Prerequisites>> and install or update your version of Visual Studio.
|
||||
|
||||
image::cpp-runtime-error.png[]
|
||||
|
||||
Unix variants:
|
||||
|
||||
[source]
|
||||
----
|
||||
./bootstrap.sh
|
||||
./b2
|
||||
./b2 install --prefix=/usr/local
|
||||
----
|
||||
|
||||
You can adjust the installation `prefix` to your preference in this command.
|
||||
|
||||
The build process creates all variants of each library.
|
||||
For example, there may be _Release_ and _Debug_ variants, or possibly _Multithreaded_ and _Static_ runtime variants.
|
||||
Also, libraries that are _header-only_ (in other words, do not require being built) are copied to your installation folder.
|
||||
|
||||
TIP: Consider using the `--show-libraries` and `--with-library=library-a --with-library=library-b` options if you want to limit the wait instead of building everything.
|
||||
--
|
||||
|
||||
CMake::
|
||||
+
|
||||
--
|
||||
You can also build the Boost libraries with CMake.
|
||||
This is the usual procedure to build and install Boost with CMake:
|
||||
|
||||
[source]
|
||||
----
|
||||
mkdir __build
|
||||
cd __build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
cmake --build . --target install
|
||||
----
|
||||
|
||||
If you are using a multi-config generator, such as Visual Studio, you can install the Debug and Release variants of the library separately with:
|
||||
|
||||
[source]
|
||||
----
|
||||
cmake --build . --target install --config Debug
|
||||
cmake --build . --target install --config Release
|
||||
----
|
||||
|
||||
Although both the boost:build[] and the CMake scripts work fine, the final installed libraries will have different layouts for historical reasons.
|
||||
Both the CMake integration scripts and the libraries will be installed under different paths and this can create incompatibilities between Boost installations.
|
||||
|
||||
TIP: You don't need to *build* Boost with CMake to be able to *use* Boost with CMake.
|
||||
CMake integration will work fine even if you install Boost with boost:build[].
|
||||
|
||||
You can find more information about the limitations of a CMake infrastructure on https://github.com/boostorg/cmake[boostorg/cmake,window="_blank"]
|
||||
--
|
||||
====
|
||||
|
||||
=== Environment variables
|
||||
|
||||
We recommend you update your environment variables after installing Boost.
|
||||
When you update your environment variables, you are telling your operating system and other tools where to look for the Boost libraries and headers.
|
||||
|
||||
[tabs,sync-group-id=os]
|
||||
====
|
||||
Windows::
|
||||
+
|
||||
--
|
||||
|
||||
[source]
|
||||
----
|
||||
set BOOST_ROOT=C:\boost <1>
|
||||
----
|
||||
|
||||
<1> Specify the root directory of the Boost pass:[C++] libraries so other tools can find it
|
||||
|
||||
IMPORTANT: Replace `C:\boost` with the prefix directory you specified during the installation, if different.
|
||||
|
||||
--
|
||||
|
||||
Linux::
|
||||
+
|
||||
--
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
export BOOST_ROOT=/usr/local <1>
|
||||
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH <2>
|
||||
export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH <3>
|
||||
----
|
||||
|
||||
<1> Specify the root directory of the Boost pass:[C++] libraries so other tools can find it
|
||||
<2> Specify additional directories to search for shared libraries when executing a program
|
||||
<3> Specify additional directories to search for pass:[C++] header files
|
||||
|
||||
IMPORTANT: Replace `/usr/local` with the prefix directory you specified during the installation, if different.
|
||||
|
||||
You can add these `export` commands to your `~/.bashrc` or `~/.profile` file to make the changes permanent.
|
||||
|
||||
--
|
||||
|
||||
macOS::
|
||||
+
|
||||
--
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
export BOOST_ROOT=/usr/local <1>
|
||||
----
|
||||
|
||||
<1> Specify the root directory of the Boost pass:[C++] libraries so other tools can find it
|
||||
|
||||
IMPORTANT: Replace `/usr/local` with the prefix directory you specified during the installation, if different.
|
||||
|
||||
You can add these `export` commands to your `~/.bashrc` or `~/.profile` file to make the changes permanent.
|
||||
|
||||
--
|
||||
====
|
||||
|
||||
[#your-first-app]
|
||||
== Your First App
|
||||
|
||||
=== Header-only libraries
|
||||
|
||||
Let’s start by using a header-only library.
|
||||
Copy the following program into a file called `example.cpp`.
|
||||
|
||||
[source,C++]
|
||||
.example.cpp
|
||||
----
|
||||
#include <boost/lambda/lambda.hpp> <1>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::lambda;
|
||||
typedef std::istream_iterator<int> in;
|
||||
|
||||
std::for_each(
|
||||
in(std::cin), in(), std::cout << (_1 * 3) << " "); <2>
|
||||
}
|
||||
----
|
||||
|
||||
<1> Including a header from the boost:lambda[] library
|
||||
<2> Reads a sequence of integers from standard input, using boost:lambda[] to multiply each number by three and write it to the standard output
|
||||
|
||||
We can now compile this program:
|
||||
|
||||
[tabs,sync-group-id=build]
|
||||
========
|
||||
CMake::
|
||||
+
|
||||
--
|
||||
You can use https://cmake.org/[CMake,window="_blank"] to configure a project to use Boost and your `example.cpp`.
|
||||
Here's an example `CMakeLists.txt` file that uses Boost:
|
||||
|
||||
[source,cmake]
|
||||
.CMakeLists.txt
|
||||
----
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(MyProject)
|
||||
|
||||
find_package(Boost REQUIRED)
|
||||
add_executable(MyProject example.cpp)
|
||||
target_link_libraries(MyProject Boost::headers)
|
||||
----
|
||||
|
||||
Store this file next to your `example.cpp` and run the basic CMake workflow:
|
||||
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
mkdir build <1>
|
||||
cd build <2>
|
||||
cmake .. -D BOOST_ROOT=path/to/{release_basename} <3>
|
||||
cmake --build . <4>
|
||||
----
|
||||
|
||||
<1> Create a `build` directory which should store the results
|
||||
<2> Change the current working directory to `build`
|
||||
<3> Run the CMake configure step, providing it with the Boost directory
|
||||
<4> Build the project
|
||||
|
||||
If using CMake >=3.13, this can be simplified to:
|
||||
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
cmake -S . -B build -D BOOST_ROOT=path/to/{release_basename}
|
||||
cmake --build build
|
||||
----
|
||||
|
||||
In either case, the resulting executable should be available in the `build` directory.
|
||||
|
||||
--
|
||||
|
||||
Visual Studio::
|
||||
+
|
||||
--
|
||||
|
||||
* Open Visual Studio and select *Create a new project*
|
||||
* Choose *Console App* from the range of project templates.
|
||||
* Change the names in the *Configure your new project* dialog, or leave the defaults, and click *Create*.
|
||||
* Replace all the boilerplate content of the .cpp file with the contents of the `example.cpp` file, noting the inclusion of the header from Boost: *lambda.hpp*.
|
||||
* Right-click on the name of the project in the *Solution Explorer* pane, and select *Properties*.
|
||||
* Under *C/C++* select *General*, then click on *Additional Include Directories*
|
||||
* Add the path to your Boost *include* folder, that will have been built in the previous section.
|
||||
|
||||
image::additional-include-directories.png[]
|
||||
|
||||
* Next, still in the project properties, select *Linker*, then *General*, and locate the *Additional Library Directories*
|
||||
* Add the path to the Boost *lib* folder.
|
||||
|
||||
image::additional-library-directories.png[]
|
||||
|
||||
* Click *OK* to accept your input.
|
||||
|
||||
You can already run your example from Visual Studio:
|
||||
|
||||
* In the *Debug* menu, select *Start Without Debugging*, or press the F5 key.
|
||||
* A Command Prompt should open up, so enter a list of numbers separated by spaces, and then *Enter*.
|
||||
* You should get a line of numbers, your originals multiplied by 3.
|
||||
|
||||
image:first-app-running.png[]
|
||||
|
||||
[TIP]
|
||||
====
|
||||
Visual Studio provides support for CMake since Visual Studio 2017. CMake is a cross-platform build system that can generate build files for a variety of build tools, including Visual Studio solutions, makefiles, and ninja files.
|
||||
By supporting CMake, Visual Studio is able to provide a consistent development experience across multiple platforms and build tools.
|
||||
Additionally, the ability to generate CMake projects from Visual Studio allows developers to take advantage of Visual Studio's debugging and profiling tools while still using their preferred build system.
|
||||
|
||||
While Visual Studio provides a user friendly environment for building software, it may not always be the best choice for managing complex projects with multiple dependencies.
|
||||
In such cases, it is recommended to consider using CMake, a popular and flexible build system that can generate build files for a variety of build tools.
|
||||
You can have the option of using CMake to manage your complex projects, while still using Visual Studio's robust development and debugging features.
|
||||
====
|
||||
|
||||
--
|
||||
|
||||
By Hand::
|
||||
+
|
||||
--
|
||||
In the directory where you saved *example.cpp*, issue the following command:
|
||||
|
||||
Visual Studio Compiler:
|
||||
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
cl /I C:\boost\include example.cpp
|
||||
----
|
||||
|
||||
GCC:
|
||||
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
g++ -I /usr/local/include example.cpp -o example
|
||||
----
|
||||
|
||||
Clang:
|
||||
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
clang++ -I /usr/local/include example.cpp -o example
|
||||
----
|
||||
|
||||
NOTE: Replace `C:\boost` or `/usr/local` with your Boost installation prefix if necessary.
|
||||
|
||||
[TIP]
|
||||
====
|
||||
It is generally not recommended to use these commands by hand for complex projects, as managing all the compile and link options can quickly become unwieldy.
|
||||
Using a build system like CMake or Make can greatly simplify the process of building and managing a project, particularly when dealing with large codebases or dependencies.
|
||||
|
||||
Using a build system also has other advantages, such as easier dependency management, the ability to easily configure the build for different platforms or compilers, and the ability to easily integrate with other tools such as version control systems and automated testing frameworks.
|
||||
====
|
||||
|
||||
--
|
||||
========
|
||||
|
||||
To test the result, run the executable from the path where it was built:
|
||||
|
||||
[tabs,sync-group-id=os]
|
||||
====
|
||||
Windows::
|
||||
+
|
||||
--
|
||||
[source]
|
||||
----
|
||||
echo 1 2 3 | example
|
||||
----
|
||||
--
|
||||
|
||||
Linux::
|
||||
+
|
||||
--
|
||||
[source]
|
||||
----
|
||||
echo 1 2 3 | ./example
|
||||
----
|
||||
--
|
||||
|
||||
macOS::
|
||||
+
|
||||
--
|
||||
[source]
|
||||
----
|
||||
echo 1 2 3 | ./example
|
||||
----
|
||||
--
|
||||
====
|
||||
|
||||
Did you get the expected result?
|
||||
|
||||
=== Compiled Libraries
|
||||
|
||||
In this section, we will locate an example from GitHub, and then build and run a project based on the example.
|
||||
|
||||
For most Boost libraries, there is an `example` sub-folder containing a range of examples.
|
||||
For this guide, we will locate an example that reads a JSON file, and pretty-prints its contents.
|
||||
|
||||
Copy all the code from https://github.com/boostorg/json/blob/develop/example/pretty.cpp[`json/example/pretty.cpp`,window="_blank"] into your `example.cpp`.
|
||||
Let's compile it:
|
||||
|
||||
[tabs,sync-group-id=build]
|
||||
========
|
||||
CMake::
|
||||
+
|
||||
--
|
||||
Edit the contents of `CMakeLists.txt`:
|
||||
|
||||
[source,cmake]
|
||||
.CMakeLists.txt
|
||||
----
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(MyProject)
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS json)
|
||||
add_executable(MyProject main.cpp)
|
||||
target_link_libraries(MyProject Boost::json)
|
||||
----
|
||||
|
||||
In this example, we explicitly require `json` as boost:json[] is a compiled library.
|
||||
Compiled libraries need to be explicitly required and linked separately.
|
||||
|
||||
Run the commands for the usual CMake workflow once more to build the executable.
|
||||
|
||||
NOTE: Note how the difference between header-only and compiled libraries is transparent when using a build system.
|
||||
--
|
||||
|
||||
Visual Studio::
|
||||
+
|
||||
--
|
||||
. Create a new Visual Studio pass:[C++] Console App.
|
||||
Name it JsonPrint.
|
||||
. Update both the additional include directories, and additional library directories, as you did for the previous section.
|
||||
. Copy all the code from https://github.com/boostorg/json/blob/develop/example/pretty.cpp, and use it to replace all the default content of the project's cpp file.
|
||||
|
||||
You can already run your example from Visual Studio:
|
||||
|
||||
. Search your computer for any JSON file, unless you have one you would like to use already.
|
||||
Record the full path to that file.
|
||||
|
||||
. In Visual Studio, locate and select *Build Solution*.
|
||||
|
||||
You should get neatly formatted output:
|
||||
|
||||
image:json-example-running.png[]
|
||||
|
||||
[circle]
|
||||
* If your JSON included symbols such as the umlaut, these will not be rendered correctly unless you change the format of your Command Prompt to UTF-8. By default, a Command Prompt supports a code page numbered 437. To change the code page to UTF-8, type `chcp 65001`.
|
||||
|
||||
* If you get compile errors such as `cannot open file 'libboost_json-vc143-mt-gd-x64-1_81.lib'` you have probably not entered the *Additional Library Directories* correctly.
|
||||
--
|
||||
|
||||
By Hand::
|
||||
+
|
||||
--
|
||||
Repeat the instructions to read the compile the executable:
|
||||
|
||||
In the directory where you saved `example.cpp`, issue the following command:
|
||||
|
||||
Visual Studio Compiler:
|
||||
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
cl /I C:\boost\include /link C:\boost\lib\libboost_json-vc71-mt-d-x86-1_34.lib example.cpp
|
||||
----
|
||||
|
||||
GCC:
|
||||
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
g++ -I /usr/local/include example.cpp -L /usr/local/libboost_json.a -o example
|
||||
----
|
||||
|
||||
Clang:
|
||||
|
||||
[source,none,subs="attributes+"]
|
||||
----
|
||||
clang++ -I /usr/local/include example.cpp -L /usr/local/libboost_json.a -o example
|
||||
----
|
||||
|
||||
NOTE: Replace `C:\boost` or `/usr/local` with your Boost installation prefix if necessary.
|
||||
|
||||
As boost:json[] is a compiled library, we need the linker option in our example.
|
||||
The name of the library file might vary according to your architecture and the options provided to `b2` while installing boost.
|
||||
Check the `lib` in your installation prefix.
|
||||
--
|
||||
========
|
||||
|
||||
Search your computer for any JSON file, unless you have one you would like to use already.
|
||||
Record the full path to that file and run the example with:
|
||||
|
||||
[tabs,sync-group-id=os]
|
||||
====
|
||||
Windows::
|
||||
+
|
||||
--
|
||||
[source]
|
||||
----
|
||||
example "path/to/json/file.json"
|
||||
----
|
||||
--
|
||||
|
||||
Linux::
|
||||
+
|
||||
--
|
||||
[source]
|
||||
----
|
||||
./example "path/to/json/file.json"
|
||||
----
|
||||
--
|
||||
|
||||
macOS::
|
||||
+
|
||||
--
|
||||
[source]
|
||||
----
|
||||
./example "path/to/json/file.json"
|
||||
----
|
||||
--
|
||||
====
|
||||
|
||||
Did you get the expected result?
|
||||
|
||||
=== Summary
|
||||
|
||||
Although the samples you have now built and run are quite simple, if you have got this far successfully, it means your build, installation and project linking are all working correctly.
|
||||
Great job!
|
||||
|
||||
=== Next Steps
|
||||
|
||||
You might like to scan the examples folders of some of the other libraries that you are interested in, and create and run projects to get them running.
|
||||
|
||||
Once you are more experienced with Boost, you might like to build and install only those libraries you require.
|
||||
|
||||
== Package Managers
|
||||
|
||||
While we provide instructions for downloading and building the libraries from source, installing Boost using a package manager might simplify the process and ensure that all dependencies are installed correctly in some cases.
|
||||
In this guide, we will discuss two types of package managers: pass:[C++] package managers such as Conan and Vcpkg, and system package managers such as Homebrew and APT.
|
||||
|
||||
While using a package manager can simplify the installation process, there are some potential downsides to consider, such as a lack of control over the installation process and potential version conflicts with other installed software.
|
||||
We will discuss these in more detail below.
|
||||
|
||||
=== pass:[C++] Package Managers
|
||||
|
||||
pass:[C++] package managers are a popular choice for managing dependencies in pass:[C++] projects.
|
||||
They provide a simple and consistent way to download, configure, and install libraries and their dependencies that's replicable on various platforms.
|
||||
However, these installation methods are not officially supported, which means the packages are not regularly tested by Boost authors.
|
||||
|
||||
[tabs]
|
||||
========
|
||||
Vcpkg::
|
||||
+
|
||||
--
|
||||
To install Boost with Vcpkg, you can run a command like:
|
||||
|
||||
[source]
|
||||
----
|
||||
vcpkg install boost
|
||||
----
|
||||
|
||||
You can also install individual boost modules by providing their name as a suffix:
|
||||
|
||||
[source]
|
||||
----
|
||||
vcpkg install boost-variant2
|
||||
----
|
||||
|
||||
To verify access to Boost libraries, enter:
|
||||
|
||||
[source]
|
||||
----
|
||||
vcpkg search boost
|
||||
----
|
||||
|
||||
You should see a full list of the Boost libraries you have installed.
|
||||
|
||||
A better approach, however, is adding these dependencies to your project manifest file.
|
||||
Follow the instruction in https://learn.microsoft.com/en-us/vcpkg/users/manifests[the introduction guide] to manifest files.
|
||||
--
|
||||
|
||||
Conan::
|
||||
+
|
||||
--
|
||||
You can install Boost with Conan through the https://conan.io/center/boost[boost] package.
|
||||
--
|
||||
========
|
||||
|
||||
=== System Package Managers
|
||||
|
||||
Depending on your operating system, you may have different package managers available.
|
||||
For instance, on Debian-based Linux distributions, APT is a popular choice, while macOS users often use Homebrew, and Windows users may prefer Chocolatey.
|
||||
Depending on your variant of Unix, you can use a package manager such as *apt*, *dnf*, *yum*, or *pacman*.
|
||||
While using a system package manager has its advantages, there are also some drawbacks to consider.
|
||||
These include potential version conflicts with system libraries, lack of control over the installation process, and the high likelihood of using outdated or unsupported versions of the Boost libraries, which may be several years old.
|
||||
|
||||
[tabs]
|
||||
========
|
||||
Ubuntu::
|
||||
+
|
||||
--
|
||||
To install the Boost pass:[C++] libraries onto Debian-based systems (such as Debian, Ubuntu), you can use the package manager apt.
|
||||
|
||||
[source]
|
||||
----
|
||||
# Update your package list
|
||||
sudo apt update
|
||||
# Install the Boost development libraries
|
||||
sudo apt install libboost-all-dev
|
||||
----
|
||||
--
|
||||
|
||||
Fedora::
|
||||
+
|
||||
--
|
||||
To install the Boost pass:[C++] libraries on Fedora, you can use the package manager *dnf*.
|
||||
|
||||
[source]
|
||||
----
|
||||
# Update your package list
|
||||
sudo dnf update
|
||||
# Install the Boost development libraries
|
||||
sudo dnf install boost-devel
|
||||
----
|
||||
|
||||
The Boost libraries are usually available as pre-compiled packages in the official Fedora repositories.
|
||||
--
|
||||
|
||||
CentOS::
|
||||
+
|
||||
--
|
||||
To install the Boost pass:[C++] libraries on CentOS, you can use the package manager *yum*.
|
||||
|
||||
Note::
|
||||
If you are using CentOS 8 or later, you might need to enable the PowerTools repository to get the Boost development libraries:
|
||||
|
||||
[source]
|
||||
----
|
||||
sudo yum config-manager --set-enabled powertools
|
||||
----
|
||||
|
||||
[source]
|
||||
----
|
||||
# Update your package list
|
||||
sudo yum update
|
||||
# Install the Boost development libraries
|
||||
sudo yum install boost-devel
|
||||
----
|
||||
|
||||
The Boost libraries are usually available as pre-compiled packages in the official CentOS repositories.
|
||||
--
|
||||
|
||||
Arch::
|
||||
+
|
||||
--
|
||||
To install the Boost pass:[C++] libraries onto Arch-based systems (such as Arch Linux, Manjaro), you can use the package manager *pacman*.
|
||||
|
||||
[source]
|
||||
----
|
||||
# Update your package list
|
||||
sudo yum update
|
||||
# Install the Boost development libraries
|
||||
sudo pacman -S boost
|
||||
----
|
||||
--
|
||||
|
||||
Homebrew::
|
||||
+
|
||||
--
|
||||
https://brew.sh/[Homebrew,window="_blank"] is a package manager for macOS that allows users to easily install, manage, and update a wide range of software packages and libraries from the command line.
|
||||
|
||||
[source]
|
||||
----
|
||||
# Update your package list
|
||||
brew update
|
||||
brew upgrade
|
||||
# Install the Boost development libraries
|
||||
brew install boost
|
||||
----
|
||||
|
||||
Homebrew will download and install the Boost libraries and their dependencies.
|
||||
To verify that the Boost libraries are installed correctly, you can run the following command:
|
||||
|
||||
[source]
|
||||
----
|
||||
brew list boost
|
||||
----
|
||||
--
|
||||
========
|
||||
|
||||
Once the installation is complete, the Boost libraries will be installed on your system, typically in `/usr`.
|
||||
To verify that the Boost libraries have been installed correctly, you can check the version number:
|
||||
|
||||
[source]
|
||||
----
|
||||
cat /usr/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
|
||||
----
|
||||
|
||||
This command should output the Boost version installed on your system.
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ There are many advantages to using Boost in your C++ projects, the main one bein
|
||||
|
||||
== Considerations when using Boost
|
||||
|
||||
The libraries implement a modern approach to C++ programming, generally prioritizing performance, correctness, cross-platform portability, efficiency and reusability. Boost offers building blocks, rather than a high-level app framework.
|
||||
The libraries implement a modern approach to C++ programming, generally prioritizing performance, correctness, cross-platform portability, efficiency and reusability. Boost offers building blocks, rather than a high-level app framework.
|
||||
|
||||
Boost is template-heavy, in order to provide portability and reusability, but this does make for dense syntax, which can take some getting used to.
|
||||
|
||||
@@ -83,6 +83,4 @@ The purpose of the Boost libraries is to evangelize and support C++ development.
|
||||
If you are new to Boost, the recommended next step is to download the entire library for your selected OS, and build a few small sample programs.
|
||||
|
||||
[square]
|
||||
* xref:getting-started-with-windows.adoc[Getting Started with Windows]
|
||||
* xref:getting-started-with-linux.adoc[Getting Started with Linux]
|
||||
* xref:getting-started-with-macos.adoc[Getting Started with macOS]
|
||||
* xref:getting-started.adoc[]
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
= Use Boost with Linux and a Package Manager
|
||||
:navtitle: Boost Linux Package Manager
|
||||
|
||||
Depending on your version of Unix, you can use a package manager such as *apt*, *dnf*, *yum*, or *pacman*. You can also install and use the *vcpkg* package manager.
|
||||
|
||||
== To Install Boost onto Debian-based Systems
|
||||
|
||||
To install the Boost C++ libraries onto Debian-based systems (such as Debian, Ubuntu), you can use the package manager *apt*. Follow these steps to install the Boost libraries:
|
||||
|
||||
. Open a terminal window.
|
||||
|
||||
. Update your package manager's repository cache. Use the following command:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo apt update
|
||||
----
|
||||
|
||||
. Install the Boost development libraries using your package manager. For Ubuntu or Debian-based distributions, you can use the following command:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo apt install libboost-all-dev
|
||||
----
|
||||
|
||||
+
|
||||
This command installs all the Boost development libraries available in the package repository.
|
||||
|
||||
. <<Verify your Boost Installation>>.
|
||||
|
||||
== To Install Boost onto Fedora
|
||||
|
||||
To install the Boost C++ libraries on Fedora, you can use the package manager *dnf*. The Boost libraries are usually available as pre-compiled packages in the official Fedora repositories. Follow these steps to install the Boost libraries:
|
||||
|
||||
. Open a terminal window.
|
||||
|
||||
. Update your package list to ensure you're getting the most recent version of the Boost libraries available in the repositories:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo dnf update
|
||||
----
|
||||
|
||||
. Install the Boost development libraries by running:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo dnf install boost-devel
|
||||
----
|
||||
+
|
||||
This command installs the core Boost libraries and their development files. If you need additional libraries, you can search for specific Boost packages using the *dnf* search command, and install them individually.
|
||||
|
||||
. <<Verify your Boost Installation>>.
|
||||
|
||||
== To Install Boost onto CentOS
|
||||
|
||||
To install the Boost C++ libraries on CentOS, you can use the package manager *yum*. The Boost libraries are usually available as pre-compiled packages in the official CentOS repositories. Follow these steps to install the Boost libraries:
|
||||
|
||||
. Open a terminal window.
|
||||
|
||||
+
|
||||
Note::
|
||||
If you are using CentOS 8 or later, you might need to enable the PowerTools repository to get the Boost development libraries:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo yum config-manager --set-enabled powertools
|
||||
----
|
||||
|
||||
. Update your package list to ensure you're getting the most recent version of the Boost libraries available in the repositories:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo yum update
|
||||
----
|
||||
|
||||
. Install the Boost development libraries by running:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo yum install boost-devel
|
||||
----
|
||||
+
|
||||
This command installs the core Boost libraries and their development files. If you need additional libraries, you can search for specific Boost packages using the *yum* search command, and install them individually.
|
||||
|
||||
. <<Verify your Boost Installation>>.
|
||||
|
||||
== To Install Boost onto Arch-based Systems
|
||||
|
||||
To install the Boost C++ libraries onto Arch-based systems (such as Arch Linux, Manjaro), you can use the package manager *pacman*. Follow these steps to install the Boost libraries:
|
||||
|
||||
. Open a terminal window.
|
||||
|
||||
. Update your package list to ensure you're getting the most recent version of the Boost libraries available in the repositories:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo pacman -Syu
|
||||
----
|
||||
|
||||
. Install the Boost development libraries by running:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo pacman -S boost
|
||||
----
|
||||
|
||||
. <<Verify your Boost Installation>>.
|
||||
|
||||
== To Install Boost with the vcpkg Package Manager
|
||||
|
||||
You can use vcpkg on Linux. To install vcpkg on a Linux system, follow these steps:
|
||||
|
||||
. Open a terminal. Install the necessary packages for building vcpkg by running the following command (for Ubuntu or Debian-based systems):
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential tar curl zip unzip git
|
||||
----
|
||||
|
||||
+
|
||||
For other Linux distributions, install the equivalent packages using the appropriate package manager, such as _yum_, _dnf_, or _pacman_.
|
||||
|
||||
. Clone the vcpkg repository from GitHub by running the following command:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
git clone https://github.com/microsoft/vcpkg.git
|
||||
----
|
||||
|
||||
+
|
||||
This command will create a new directory named "vcpkg" in your current directory and clone the repository into it.
|
||||
|
||||
. Change to the *vcpkg* directory: `cd vcpkg`. Then run the bootstrap script to build the vcpkg executable:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
./bootstrap-vcpkg.sh
|
||||
----
|
||||
|
||||
+
|
||||
This script will download and build the necessary components for vcpkg. It might take a few minutes to complete.
|
||||
|
||||
. (Optional) Add the vcpkg executable to your system's PATH environment variable. This step makes it easier to run vcpkg from any directory. Run the following command:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
export PATH=$PATH:$(pwd)
|
||||
----
|
||||
|
||||
+
|
||||
To make this change permanent, add the above export command to your shell's configuration file, such as `~/.bashrc` or `~/.bash_profile` for the Bash shell.
|
||||
|
||||
. Now, vcpkg is installed on your Linux system, and you can start using it to manage your C++ project dependencies. To install a package, you can run a command like:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
./vcpkg install <package-name>
|
||||
----
|
||||
|
||||
+
|
||||
Replace `<package-name>` with the name of the package you want to install.
|
||||
|
||||
. <<Verify your Boost Installation>>.
|
||||
|
||||
== Verify your Boost Installation
|
||||
|
||||
Once the installation is complete, the Boost libraries will be installed on your system, typically in */usr/include/boost* and */usr/lib64*(for 64-bit systems) or */usr/lib* (for 32-bit systems).
|
||||
|
||||
. To verify that the Boost libraries have been installed correctly, you can check the version number:
|
||||
|
||||
+
|
||||
[source]
|
||||
----
|
||||
cat /usr/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
|
||||
----
|
||||
|
||||
+
|
||||
This command should output the Boost version installed on your system.
|
||||
|
||||
. To use the libraries in your projects, you may need to configure your build system to include the appropriate header and library paths.
|
||||
|
||||
== Next Steps
|
||||
|
||||
xref:getting-started-with-linux.adoc#your-first-app[Your First App]
|
||||
@@ -1,92 +0,0 @@
|
||||
= Use Boost with Windows and a Package Manager
|
||||
:navtitle: Boost Windows Package Manager
|
||||
|
||||
This section describes how to manage Boost libraries using the *vcpkg* package manager. It is an open source and free app.
|
||||
|
||||
== Advantages of using vcpkg
|
||||
|
||||
A package manager like *vcpkg* can add value by streamlining the process of managing dependencies in a software project. It can be particularly helpful in C++ projects, which often have complex dependency chains. Some of the key benefits of using *vcpkg* include:
|
||||
|
||||
[disc]
|
||||
* Simplified dependency management: *vcpkg* automates the process of downloading, building, and installing libraries, saving developers time and effort.
|
||||
|
||||
* Consistent environment: *vcpkg* ensures that all developers on a team use the same library versions, helping to avoid inconsistencies and bugs that can arise from using different library versions in different environments.
|
||||
|
||||
* Cross-platform support: *vcpkg* supports multiple platforms, including Windows, macOS, and Linux, making it easier to develop cross-platform projects.
|
||||
|
||||
* Binary caching: *vcpkg* caches compiled binaries, speeding up subsequent builds and installations of the same libraries across different projects.
|
||||
|
||||
* Version control: *vcpkg* allows developers to specify the exact version of a library they want to use, ensuring that updates to libraries do not introduce breaking changes to their projects.
|
||||
|
||||
* Library discovery: *vcpkg* has a large catalog of available libraries, making it easy for developers to discover and use new libraries in their projects.
|
||||
|
||||
* Integration with build systems: *vcpkg* integrates with popular build systems like CMake, simplifying the process of adding dependencies to a project.
|
||||
|
||||
* Regular updates and maintenance: *vcpkg* is actively maintained and updated by Microsoft, ensuring that the package manager and its libraries stay current and compatible with the latest development tools and practices.
|
||||
|
||||
By providing these benefits, a package manager like *vcpkg* helps developers to focus on writing code and building features, rather than spending time on managing dependencies manually.
|
||||
|
||||
== Install the Package Manager
|
||||
|
||||
To install *vcpkg* on a Windows PC, follow these steps:
|
||||
|
||||
. Open a Command Prompt or PowerShell with administrative privileges. You can do this by searching for *cmd* or *PowerShell* in the Start menu, right-clicking on the relevant result, and choosing *Run as administrator*.
|
||||
|
||||
. Clone the *vcpkg* repository from GitHub by running the following command:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
git clone https://github.com/microsoft/vcpkg.git
|
||||
----
|
||||
+
|
||||
This command will create a new directory named *vcpkg* in your current directory and clone the repository into it. If you don't have Git installed, you can download it from https://git-scm.com/downloads and install it.
|
||||
|
||||
. Change to the *vcpkg* directory using the `cd` command:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
cd vcpkg
|
||||
----
|
||||
|
||||
. Run the bootstrap script to build the *vcpkg* executable:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
.\bootstrap-vcpkg.bat
|
||||
----
|
||||
+
|
||||
This script will download and build the necessary components for vcpkg. It might take a few minutes to complete.
|
||||
|
||||
. (Optional) Add the *vcpkg* executable to your system's PATH environment variable. This step makes it easier to run *vcpkg* from any directory. Run the following command:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
.\vcpkg integrate install
|
||||
----
|
||||
+
|
||||
After running this command, you'll see a message with instructions on how to add *vcpkg* to your user-wide environment. Follow the instructions to ensure you can use *vcpkg* from any directory.
|
||||
|
||||
== Using the Package Manager
|
||||
|
||||
Now, *vcpkg* is installed on your Windows PC, and you can start using it to manage your C++ project dependencies.
|
||||
|
||||
. To install a package, you can run a command like:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
.\vcpkg install boost
|
||||
----
|
||||
+
|
||||
Replace `boost` with the name of any additional package you want to install.
|
||||
|
||||
. To verify access to Boost libraries, enter:
|
||||
+
|
||||
[source]
|
||||
----
|
||||
.\vcpkg search boost
|
||||
----
|
||||
+
|
||||
You should see a full list of the Boost libraries you have installed.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user