azure-sdk-for-cpp/samples/integration/vcpkg-storage
Wes Haggard 015c34a029
Update links from master to main (#2488)
* Update links from master to main

* Upate other references from master to main
2021-06-24 22:27:14 -07:00
..
.devcontainer
src Consolidate the use of std::size_t and always use size_t instead, since it is a "primitive" type. (#2415) 2021-06-09 11:09:54 -07:00
CMakeLists.txt Update upper/lower/other casing (#2267) 2021-05-14 12:54:16 -07:00
LICENSE
README.md Update links from master to main (#2488) 2021-06-24 22:27:14 -07:00

Integrating the Azure SDK for C++ into your application using vcpkg

This application shows how to integrate the Azure SDK for C++ in your application. It uses vcpkg to adquire and build the Azure SDK for C++ client libraries. Your CMake project needs to link the libraries from vcpkg by setting the toolchain file to vcpkg (shown below).

Pre-requisites

There are two options to set up the development environment:

Manual installation

Install the Azure SDK for C++ dependencies.

  • CMake project (min version 3.13).
  • C++ version 14 or greater.

Container

The sample provides a .devcontainer folder which can be used by VS Code to build and run a docker container with the required C++ build tools and with vcpkg installed.

This method requires VS Code + Remote Container to be installed in the system. Also make sure to have Docker installed and running. This method works for any operating system where Docker and VS Code is supported like Windows, Linux and macOS. The development environment will be Debian 10.

  • Open vcpkg folder in VS Code.
  • VS Code will detect the devcontainer configuration and ask you if you would like to re-open the folder in a container. Click Yes.
  • If VS Code did not ask, you can press F1 and type Reopen in container option.

Once VS Code builds and run the container, open the terminal and continue to build step.

Note: The container is set up to automatically link vcpkg to CMake projects by setting env variables that the CMake sample project will use to set the toolchain.

Build

Linux terminal

#
# Building the application.
# Instructions from application root directory.
#

# Create build directory just the first time.
mkdir build
cd build

# Generate and build
# This code assumes that the SDK dependencies were installed with vcpkg
# When using docker provided container, the TOOLCHAIN option is not required (cmake ..).
cmake -DCMAKE_TOOLCHAIN_FILE=path/to/vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake -build .

Windows VS

If you are using Visual Studio, the toolchain to link vcpkg is set with CMakeSettings.json. Upate this file and set the vcpkg toolchain file for vcpkg (VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake). After setting the toolchain, VS can generate and build the sample. Use VS to open the sample folder only.

Run application

Review source code header for environment variables that must be set up before running the app.

#
# Running the Application
# Instructions from inside the build directory.
#

# Run binary (.exe on Windows)
./application