I’m asking this question to make sure I’m doing the right thing, as my knowledge on cmake is very limited. My purpose is to make a shared library with libtorch, so I tried a toy model based on the install libtorch example. After checking some stackoverflow answers, I found that the only thing I need to do is to change the following line in the
CMakeLists.txt - Minimal Example from:
add_library(example-app SHARED example-app.cpp)
example-app.cpp needs to be changed to a library code accordingly, say changing the
main function to a lib function
Then with the same build command in the Minimal Example:
mkdir build cd build cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch .. cmake --build . --config Release
I’ll get a
lib<xxx>.so that can be readily used. After that, as long as I have the
libtorch/ shared libraries in my computer, I can use that shared object for the other binaries.
- Am I doing it in the right way?
- Do I have any redundant or missing steps?