Building C# bindings for ADLX
Navigation: Programming with ADLX → ADLX Programming Guide → Quick Start
This guide outlines the steps to build a C# binding wrapper for ADLX, a prerequisite to programming with ADLX in a C# application.
Prerequisite(s)
- ADLX SDK is installed.
- Visual Studio 2019 is installed.
- swigwin 4.0.2 is installed, and the path to the swigwin 4.0.2 installation is added to the Path user environment variable.
To build ADLX bindings in C#
- Create and name a folder for the C# ADLX binding wrapper, for example
ADLXCSharpBind
. - Create a new file in the
ADLXCSharpBind
folder and title itADLXCSharpBind.i
. - Edit
ADLXCSharpBind.i
and add the SDK header files for the interfaces you wish to wrap by using the SWIG input format. To create bindings for event notifications, turn on thedirector
wrapping callback for respective listener interfaces.
For example,
feature("director") IADLXDisplayListChangedListener;
Note: Refer to the C# samples ADLXCSharpBind.i file for an example of a C# binding.
- Create a C++ Dynamic Link Library project named
ADLXCSharpBind
and configure the project as follows: - | Key | Value | Observations | |---|---|---| | C/C++ > Precompiled Header | Not Using Precompiled Headers | Do not use precompiled headers |
- Add the
ADLXCSharpBind.i
file to the project. - Right-click the
ADLXCSharpBind.i
file, and select Properties from the menu. In the Properties dialog select Configuration Properties > General > Item Type > Custom Build Tool.
Set the configuration as follows:
- | Key | Value | Observations |
|---|---|---|
| Command Line | if not exist (SolutionDir)out swig.exe -c++ -csharp -dllimport ADLXCSharpBind -outdir ../out/ ADLXCSharpBind.i | Invoke SWIG.exe to build
ADLXCSharpBind.i
file | | Outputs | %(Filename)_wrap.cxx | Set output file name format | - Build the project.
Result: The following files are added to the ADLXCSharpBind
project output folder:
ADLXCSharpBind_wrap.h
file.ADLXCSharpBind_wrap.cxx
file.- All *.cs files that correspond to the additional interfaces in the
ADLXCSharpBind.i
file. - Add the following files to the project:
ADLXCSharpBind_wrap.h
ADLXCSharpBind_wrap.cxx
SDK/Platform/Windows/WinAPIs.cpp
SDK/ADLXHelper/Windows/Cpp/ADLXHelper.h
SDK/ADLXHelper/Windows/Cpp/ADLXHelper.cpp
- Rebuild the project.
Result: The ADLXCSharpBind.dll
is built in the "$(SolutionDir)$(Platform)$/(Configuration)/"
folder.
See Also: ADLXCSharpBind