Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[cmake][cpp-package] Building with cmake does not install the cpp-package API #12849

Open
inglada opened this issue Oct 17, 2018 · 9 comments
Open

Comments

@inglada
Copy link

inglada commented Oct 17, 2018

Hi,
I have successfully built mxnet from sources on Debian stretch using cmake. The cpp-package is correctly built. However, the "make install" step only installs the library and the header files for the C API, but not the ones for the cpp-package.
Thanks.

@leleamol
Copy link
Contributor

Hi,
The cpp-package APIs do not get install after running 'make install'.
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.
#include <mxnet-cpp/MxNetCpp.h>

While building the program, ensure that the correct paths to the directories containing header files and MXNet shared library are specified. Typically, paths to the following directories in the MXNet respository would be needed. The 'incubator-mxnet' in following path is a directory where MXNet Github repository is cloned (recursively.)
incubator-mxnet\3rdparty\tvm\nnvm\include
incubator-mxnet\dmlc-core\include
incubator-mxnet\include

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.

Please note that the cpp-package API are not standalone API yet. The MXNet sources are needed to be accessible while building the program that intends to use cpp-package API.

Please refer to Makefile in cpp-package/example directory.

I hope this helps.
-Amol

@lanking520
Copy link
Member

@mxnet-label-bot please add [c++, installation]

@marcoabreu marcoabreu added C++ Related to C++ Installation labels Oct 17, 2018
@inglada
Copy link
Author

inglada commented Oct 18, 2018

Hi,
Thanks for your answer. I am using CMake instead of the provided makefile in order to avoid an in-source build and also in order to be able to "consume" mxnet with cmake's find_package.
As far as I understand, the current CMake build just replaces the provided makefile so that mxnet can be built on Windows, but it does not provide a "true" CMake build.

Is my interpretation correct?

Is it possible to provide the complete CMake functionality?

Thanks.

@leleamol
Copy link
Contributor

@inglada I am not very expert on CMake or how it is used in this repo. Someone from @mxnet-jenkins team might be able to answer.

@marcoabreu would you be able to answer above question?

@lebeg
Copy link
Contributor

lebeg commented Nov 19, 2018

... but it does not provide a "true" CMake build.

The cmake build can be considered as 'true' and should be used instead of make whenever possible. Currently, it's not supported only for 1 case: cross-compilation with CUDA, for example for Jetson.

The fact that installing does not include the nessesary files probably should be fixed in CMakeLists.txt

@leleamol
Copy link
Contributor

leleamol commented Jun 4, 2019

@inglada Please let us know if you were able to build cpp-package using CMakefiles so that we can close this issue.

@leleamol
Copy link
Contributor

leleamol commented Jun 4, 2019

@mxnet-label-bot add [Pending Requester Info]

@inglada
Copy link
Author

inglada commented Jun 5, 2019

@leleamol I did not go further on this. Since "make install" does not install the C++ package (only the C one) I need to add this in the CMakeLists.txt of the client projects:

include_directories(${MXNET_SOURCE_DIR}/include)
include_directories(${MXNET_SOURCE_DIR}/cpp-package/include)
include_directories(${MXNET_SOURCE_DIR}/3rdparty/tvm/nnvm/include)
include_directories(${MXNET_SOURCE_DIR}/3rdparty/tvm/3rdparty/dmlc-core/include)
link_directories(${MXNET_SOURCE_DIR}/build)
link_directories(${MXNET_SOURCE_DIR}/build/3rdparty/dmlc-core/)

But it's been I while since I last tried.

@leleamol
Copy link
Contributor

leleamol commented Jun 7, 2019

@inglada Thanks for the update.
Building the cpp-package does not produce any binary artifact. It generates "op.h" file which contains declarations of operator functions.
The updates you had mentioned in your response are needed to build programs that use API from cpp-package.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants