bazel build --config=opt --verbose_failures -c dbg --strip=never //tensorflow:libtensorflow_cc.so
bazel build --config=opt --verbose_failures -c dbg --strip=never //tensorflow:libtensorflow_framework.so
Also I have built the python pip package without an issue:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
How can I compile and link a simple C++ API example as the one shown here:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/public
I tried using simple CMakeLists.txt file like the one below but I am getting some compilation errors which are related to Eigen which is not included correctly.
/opt/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatMatProduct.h:236:1: error: 'EIGEN_DONT_INLINE' does not name a type
236 | EIGEN_DONT_INLINE void gebp_kernel<QUInt8, QInt8, Index, DataMapper, mr, nr,
| ^~~~~~~~~~~~~~~~~
Am I missing something?
Below are included my CMakeLists.txt and TensorflowApp.cxx.
Thank you in advance,
Dimitar Gueorguiev
######################CMakeLists.txt########################################
#
#
cmake_minimum_required(VERSION 3.10)
# set the project name and version
project(TensorflowApp VERSION 1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
option(USE_TF2_FRAMEWORK "Use tensorflow v2 framework library" ON)
option(USE_TF2_LIBRARY "Use tensorflow v2 cc library" ON)
configure_file(TensorflowAppConfig.h.in TensorflowAppConfig.h)
if(USE_TF2_FRAMEWORK)
list(APPEND EXTRA_LIBS tensorflow_framework)
endif()
if(USE_TF2_LIB)
list(APPEND EXTRA_LIBS tensorflow_cc)
endif()
if(USE_TF2_LIB)
add_library(tensorflow_cc SHARED IMPORTED) # or STATIC instead of SHARED
set_target_properties(tensorflow_cc PROPERTIES
IMPORTED_LOCATION "${TF_HOME}/bazel-bin/tensorflow/libtensorflow_cc.so"
INTERFACE_INCLUDE_DIRECTORIES "${TF_HOME}/bazel-tensorflow;${TF_HOME}/bazel-bin;${TF_HOME}/bazel-tensorflow/third_party/eigen3;${TF_HOME}/bazel-tensorflow/external/eigen_archive;${TF_HOME}/bazel-tensorflow/external/com_google_absl;${TF_HOME}/bazel-tensorflow/external/com_google_protobuf/src"
)
endif()
if(USE_TF2_FRAMEWORK)
add_library(tensorflow_framework SHARED IMPORTED) # or STATIC instead of SHARED
set_target_properties(tensorflow_framework PROPERTIES
IMPORTED_LOCATION "${TF_HOME}/bazel-bin/tensorflow/libtensorflow_framework.so"
INTERFACE_INCLUDE_DIRECTORIES "${TF_HOME}/bazel-tensorflow;${TF_HOME}/bazel-bin;${TF_HOME}/bazel-tensorflow/third_party/eigen3;${TF_HOME}/bazel-tensorflow/external/eigen_archive;${TF_HOME}/bazel-tensorflow/external/com_google_absl;${TF_HOME}/bazel-tensorflow/external/com_google_protobuf/src"
)
endif()
add_executable(TensorflowApp TensorflowApp.cxx)
target_include_directories(TensorflowApp PUBLIC "${PROJECT_BINARY_DIR}")
if(USE_TF2_LIB)
target_link_libraries(TensorflowApp tensorflow_cc)
endif()
if(USE_TF2_FRAMEWORK)
target_link_libraries(TensorflowApp tensorflow_framework)
endif()
####################TensorflowApp.cxx##################################
#
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/public/session.h"
#include "tensorflow/core/framework/tensor.h"
#include "TensorflowAppConfig.h"
using namespace tensorflow;
using tensorflow::string;
using tensorflow::int32;
int main (int argc, char *argv[]) {
std::cout << argv[0] << " Version " << TensorflowApp_VERSION_MAJOR << "."
<< TensorflowApp_VERSION_MINOR << std::endl;
return 0;
}
--
To unsubscribe from this group and stop receiving emails from it, send an email to build+un...@tensorflow.org.