MXNet - C++ API¶
The MXNet C++ Package provides C++ API bindings to the users of MXNet. Currently, these bindings are not available as standalone package. The users of these bindings are required to build this package as mentioned below.
Building C++ Package¶
The cpp-package directory contains the implementation of C++ API. As mentioned above, users are required to build this directory or package before using it. The cpp-package is built while building the MXNet shared library, libmxnet.so.
Steps to build the C++ package:¶
Building the MXNet C++ package requires building MXNet from source.
Clone the MXNet GitHub repository recursively to ensure the code in submodules is available for building MXNet.
git clone --recursive https://github.com/apache/incubator-mxnet mxnet
There is a configuration file for make, make/config.mk that contains all the compilation options. You can edit this file and set the appropriate options prior to running the make command.
For enabling the build of C++ Package, set the USE_CPP_PACKAGE = 1 in make/config.mk. Optionally, the compilation flag can also be specified on make command line as follows.
make -j USE_CPP_PACKAGE=1
In order to consume the C++ API please follow the steps below.
Ensure that the MXNet shared library is built from source with the USE_CPP_PACKAGE = 1.
Include the MxNetCpp.h in the program that is going to consume MXNet C++ API.
While building the program, ensure that the correct paths to the directories containing header files and MXNet shared library.
The program links the MXNet shared library dynamically. Hence the library needs to be accessible to the program during runtime. This can be achieved by including the path to the shared library in the environment variable LD_LIBRARY_PATH for Linux, Mac. and Ubuntu OS and PATH for Windows OS.
A basic tutorial can be found at https://mxnet.incubator.apache.org/tutorials/c++/basics.html.
The example directory contains examples for you to get started. For namespaces, classes, and code files for the MXNet C++ package, see the following: