Are there any supported alternatives to the approach presented on the Tensorflow C++ guide that instead allows you to separately build Tensorflow and link your C++ application to it as an external library?
I've managed to compile libtensorflow_cc.so and link to it. But where can I get valid header-files. Just grabbing the header-files from source gives errors and I have to manually adjust the paths, which I'd rather avoid.
I use this https://github.com/FloopCZ/tensorflow_cc repository and add find_package(TensorflowCC REQUIRED) in cmake and there is no issue with include file and not with lib target_link_libraries(project_name TensorflowCC::Shared)
or check that you include file path is correct to the path to you TF installation
Related
I have an existing C++ cmake project and I want to use tensorflow in it as a third party library. I searched extensively but all the solutions involve installing tensorflow at the end or copying the files to /usr/local directory.
My problem is I don't want to make any changes to the system directories and everything should happen within my project directory.
So, I compiled libtensorflow_cc.so and libtensorflow_framework.so from tensorflow source code and copied into my project directory. I added below code in my CMake to link these libraries.
find_library(tensorflowlibfwk libtensorflow_framework.so
PATHS ${PROJECT_SOURCE_DIR}/thirdparty/lib)
find_library(tensorflowlibcc libtensorflow_cc.so
PATHS ${PROJECT_SOURCE_DIR}/thirdparty/lib)
target_link_libraries(tensorflowtest ${tensorflowlibfwk} ${tensorflowlibcc})
I have no idea about which headers should I include to use the tensorflow in my project ??
Any kind of help please
I want to ask if it is possible to work with c++ source code of the opencv library, without using the compiled libraries like .lib and .dll.
I mean is it possible to work only with header files and .cpp files from the library?
I want to create a basic c++ class with a function that accepts an image and perform a series of opencv related operations, but I need the freedom to compile the code for a number of platforms as a native library (and I think that using .lib or .dll will forbid the compilation for several platforms). I guess that could be possible by using only the c++ source code. But using visual studio and adding Additional Include Directories, I do get errors LNK2019, that is probably "A function or variable is declared but not defined" although I do include the 'right' directories with .hpp's and .cpp's but probably I miss something.
This is a typical case for native code. What you need to do is download the source code (I believe you have already done that) and build it separately for platform(s) you need it for.
In your project include the result libraries (either static lib or dynamic dll files) as you would pre-compiled ones. This way library files are kept separate and built only once, not on every build of your project.
In Visual Studio you can set the include path separately for every configuration so you can set your project up to use library built for current architecture.
Adding to what #slawekwin wrote in his comment above, building and
linking dependencies on your target platforms can also be automated as
part of your build system.
If you built OpenCV before, you should have come across CMake. With
CMake it's possible to configure external projects (EP), which will
download source code of third party project and then configure, build,
and install it. This is an example for OpenCV copied from a github
repository:
ExternalProject_Add(opencv
GIT_REPOSITORY ${git_protocol}://code.opencv.org/opencv.git
GIT_TAG 2.3.1
SOURCE_DIR opencv
BINARY_DIR opencv-build
UPDATE_COMMAND ""
PATCH_COMMAND ""
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
${ep_common_args}
-DBUILD_DOCS:BOOL=OFF
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_NEW_PYTHON_SUPPORT:BOOL=OFF
-DBUILD_PACKAGE:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=ON
-DBUILD_TESTS:BOOL=OFF
# -DCMAKE_BUILD_TYPE:STRING=Release
-DWITH_FFMPEG:BOOL=OFF
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/INSTALL
)
set( OPENCV_ROOT_DIR ${CMAKE_BINARY_DIR}/INSTALL )
set( OPENCV_DIR ${CMAKE_BINARY_DIR}/INSTALL )
It could also be interesting to take a look at a cross-platform package
manager for C++ called hunter, which is based on CMake EP.
How to include flandmark library in dev c++? I need to find landmark points for eye.
There are no proper example for using flanmark in dev c++. When i included the header files in the project directory i still get linkage error.
it seems that there is still no official support for generating project for dev c++ in CMake. However, you can of course still use it. From your question it is not clear whether you have compiled flandmark library already and now want to create an external project in dev c++ using the library or if you want to compile flandmark library itself using dev c++.
If you have already successfully compiled flandmark and want to use it in external project, then besides setting the include directory and include the header files, you also need to specify linking directory and link flandmark libary to your project. See e.g. the CMakeLists.txt line 65 file for getting the idea what to include and what to link.
In case you want to use dev c++ for compiling the flandmark library, you need to link the OpenCV libraries and includes and specify the include directory with flandmark headers. For the OpenCV on linux works the command:
pkg-config --cflags --libs opencv
at the end of the g++ line.
I am building my project for Visual Studio with CMake. I used this lines in my CMakeList.txt to include FFTW3.
find_library(FFTW_LIBRARY
NAMES fftw3 fftw)
set(FFTW_LIBRARIES "${FFTW_LIBRARY}")
I got this error from CMake:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FFTW_LIBRARY
linked by target "windows_SHT" in directory C:/...
I think I did not install fftw properly. I got .dll .lib and .h files in a folder but I don't know how to explain to CMake where is the library.
Specify additional paths for find_library to use.
See: http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_library
You will need to include the path to your custom FFTW installation.
A similar technique will need to be used when you use find_file to locate the headers
http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_file
I got the following setup. I'm going to extend a framework written in C++ using MPI and other Stuff using CUDA. The Project uses cmake for building. I would like to avoid using a library for my extensions and build object files from my cuda sources. Afterwards I would like to link these object object files and some other files compiled with other compilers.
Does anyone have a clue on hwo to achieve that?
I had a look at http://code.google.com/p/cudpp/wiki/BuildingCUDPPwithCMake for getting an overview on how to use CUDA with cmake but this solution uses a library as well.
It is possible to compile object files with the CUDA support that comes with newer versions of cmake. You use the cuda_compile command. See below.
# CMakeLists.txt for G4CU project
project(test-cuda-thrust-gdb)
# required cmake version
cmake_minimum_required(VERSION 2.8)
# packages
find_package(CUDA)
# nvcc flags
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_20,code=sm_20)
cuda_compile(HELPER_O helper.cu)
cuda_compile(DRIVER_O driver.cu OPTIONS -G)
cuda_add_executable(driver ${HELPER_O} ${DRIVER_O})
If you need more information have a look at the FindCUDA.cmake file.