I've got a c++ project set up in CLion that uses CMake . I am using various 3rd party libraries and would like to also integrate Tensorflow .
I've tried bazel to compile Tensorflow to a shared library libtensorflow.so
which kind of worked however there are still quite a few dependencies (eg to a current protobuf version and once I do that there are more) that I'd have to fix.
Is there a way to use the standard Tensorflow git repository and somehow link the libraries that are pre-compiled for python usage? Or is there another convenient way?
Tensorflow in Python works well for me.
I am aware this answer is quite late, but I encountered your exact problem and was able to solve it. I created a repository here that describes how to accomplish exactly what you want. The gist is:
/usr/local
. If you have any questions or problems, don't hesitate to contact me.
If you're on MacOS, using homebrew, CMake and pkg_config
it's easy.
First get Tensorflow using brew:
brew install libtensorflow
Then in CMakeLists.txt
:
cmake_minimum_required(VERSION 3.10)
project(tf-inference)
find_package(PkgConfig)
pkg_check_modules(TensorFlow REQUIRED tensorflow)
link_directories(${TensorFlow_LIBRARY_DIRS})
include_directories(${TensorFlow_INCLUDE_DIRS})
add_compile_definitions(${TensorFlow_CFLAGS_OTHER})
add_executable(tf-inference inference.cpp)
target_link_libraries(tf-inference ${TensorFlow_LIBRARIES})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.