This guide provides instructions for integrating the AREG Framework into an existing or new Microsoft Visual Studio project on Windows. You can integrate the AREG Framework using either of the following methods:
- Install via
vcpkg
as a prebuilt package. - Add AREG SDK as a Git submodule in your project.
Tip
For a practical example of integrating AREG SDK libraries and tools, refer to the AREG SDK Demo repository.
Note
Alternatively, you can learn how to integrate AREG Framework in a project with CMake.
- AREG SDK General Requirements
- General Information
- Example Code
- Integration Methods
- Advanced Integration
To integrate the AREG SDK, ensure the following prerequisites are met:
- Git for repository management
- Supported Compilers: Microsoft Visual Studio 2019 or newer
- Java version 17+ for code generation tools
The AREG SDK includes several key components:
- AREG Framework (
areg
library): The core library for automation and Object RPC communication. - AREG Framework Extension (
aregextend
library): An optional library with additional utilities. - AREG Log Observer API (
areglogger
library): Allows applications to receive and manage log messages. - AREG Multicast Router (
mcrouter
executable): An OS-managed service that routes RPC messages. - AREG Log Collector (
logcollector
executable): An OS-managed service for remote log collection. - AREG Log Observer (
logobserver
executable): A stand-alone application for managing logs. - AREG Code Generator (
codegen.jar
runnable): A Java tool for generating Service Interface source code.
These components provide a robust foundation for integrating the AREG SDK, streamlining the development process.
Create a new Microsoft Visual Studio solution with a console project named example
. Add a file named example.cpp
with the following content:
#include "areg/base/String.hpp"
// (Optional) Link the areg library in the source code for simplicity
#pragma comment(lib, "areg")
int main() {
String str("Hello from AREG SDK!");
std::cout << str.getData() << std::endl;
return 0;
}
This example project and source file will be used throughout the integration steps.
Important
As of AREG SDK 2.0, integration via vcpkg
is supported.
-
Install
vcpkg
: Follow the instructions on the vcpkg GitHub page. Ensurevcpkg
is updated to the latest package version. If you are installingvcpkg
for the first time, close Microsoft Visual Studio to allow proper integration. -
Install the AREG SDK Package for Windows: Run the following command in PowerShell to install the AREG SDK package for Windows:
vcpkg install areg
-
Integrate Installed Package: Run the following command to integrate the AREG SDK binaries and headers with Visual Studio:
vcpkg integrate install
-
Build the
example
Project: Since the example code includes a direct link to theareg
library (#pragma comment(lib, "areg")
), no additional configuration is needed. Build theexample
project and run it.
Also see Installing and Using AREG SDK with vcpkg Package Manager for more details.
-
Define Submodule: Add the
areg-sdk
as a submodule by creating a.gitmodules
file in your project:[submodule "areg-sdk"] path = areg-sdk url = https://github.com/aregtech/areg-sdk.git
-
Download AREG SDK Sources: Run these commands to initialize and update the submodule:
git submodule update --init --recursive git submodule update --remote --recursive
-
Integrate into Visual Studio Solution:
-
Copy the
msvc_setup.props
file located in the<areg-sdk>
directory to the root of your project (where yourexample.sln
is located). -
Open
msvc_setup.props
and set the<AregSdkRoot>
property to the path of theareg-sdk
submodule. For example:<AregSdkRoot>$(SolutionDir)areg-sdk/</AregSdkRoot>
Adjust other settings, such as
AregOutputXXX
, inmsvc_setup.props
if needed to fit your project's build structure. -
Add the
areg.vcxproj
project and optionally other*.vcxproj
files located in<areg-sdk>/framework
to yourexample
solution. -
In Project -> Properties for the
example
project, navigate to C/C++ -> General -> Additional Include Directories, and add$(AregFramework)
. -
Optionally, add
$(SolutionDir)areg-sdk/thirdparty
to Additional Include Directories. -
Under C/C++ -> Preprocessor Definitions, add either
IMPORT_SHARED_SYMBOLS
(for DLL) orIMPORT_STATIC_SYMBOLS
(for static library). -
Since the
example.cpp
contains a linker instruction#pragma comment(lib, "areg")
, there is no need to linkareg.lib
anymore. But if you don't like usingpragma
in your code, in Project -> Properties for theexample
project navigate to Linker -> Input -> Additional Dependencies, addareg.lib
. Update Additional Library Directories in Linker -> General if necessary.
-
-
Build the Solution: After configuring these settings, you should be able to build all projects in the solution.
The AREG SDK project defines the following options, which can be used with MSBuild from the command line:
- AregExtended: Enables (value
1
) or disables (value0
) building with extended features in thearegextend
project. - AregLogs: Enables (value
1
) or disables (value0
) compiling projects with logging capabilities.
To build your solution with MSBuild, you can specify these options. For example, to disable extended features and logging, use:
msbuild /m /property:Configuration=Release /property:Platform=Win32 /property:AregExtended=0 /property:AregLogs=0 . -t:restore,build -p:RestorePackagesConfig=true
If you want to adopt the AREG SDK's directory structure for your projects, use the msvc-XXX.vcxproj
template files in <areg-sdk>\docs\templates
. These templates include all necessary properties and compiler settings. Copy the required files, rename them, edit the GUIDs, and add them to your solution.
Since Microsoft Visual Studio does not offer the same flexibility as CMake for dynamic builds, additional steps are needed if using the code generator:
- Create a
.bat
file with commands to generate files from Service Interface documents. - Generate the Service Interface code.
- Create a project to compile the generated files into a static library.
- Create a
dummy
project to execute the.bat
file as a pre-build step. - Set other projects to depend on
dummy
to ensure it builds first.
For a working example, refer to the .bat
file in \examples\examples_generate.bat and the dummy
project in \examples\dummy.