So when I use the command make I get the following error:
[jalal#goku c++]$ make
[ 25%] Building CXX object CMakeFiles/TestSVM.dir/TestSVM.cpp.o
[ 50%] Linking CXX executable TestSVM
CMakeFiles/TestSVM.dir/TestSVM.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
TestSVM.cpp:(.text+0x28c3): undefined reference to `USER_ERROR__inconsistent_build_configuration__see_dlib_faq_1_'
TestSVM.cpp:(.text+0x28cf): undefined reference to `USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2'
collect2: error: ld returned 1 exit status
make[2]: *** [TestSVM] Error 1
make[1]: *** [CMakeFiles/TestSVM.dir/all] Error 2
make: *** [all] Error 2
The files look like:
[jalal#goku c++]$ ls
CMakeCache.txt CMakeFiles CMakeLists.txt Makefile TestSVM.cpp TrainSVM.cpp cmake_install.cmake json.hpp trained_svms
I built the dlib in /scratch2/dlib from source using this repo:https://github.com/davisking/dlib
by following these commands:
mkdir build; cd build; cmake .. -DUSE_AVX_INSTRUCTIONS=1; cmake --build .
I am not sure how I should fix this problem.
I followed the following commands in the git repo I cloned:
$ cd c++
$ cmake .
$ make
https://github.com/sausax/pose_estimation
Additionally not sure how to make sense out of this for fixing the bug
https://github.com/davisking/dlib/blob/master/dlib/test_for_odr_violations.cpp
As the commenter said, don't forget to link to dlib! You can do this in CMake with:
target_link_libraries(<YOUR APP> dlib::dlib)
I wasn't able to get plain dlib to link, but I tried ${dlib_LIBRARIES} and finally CMake clued me in with:
CMake Warning at lib/cmake/dlib/dlibConfig.cmake:42 (message):
The variable 'dlib_LIBRARIES' is deprecated! Instead, simply use
target_link_libraries(your_app dlib::dlib). See
http://dlib.net/examples/CMakeLists.txt.html for an example.
I too was distracted by the ENABLE_ASSERTS pointing to the FAQ, but that was due to me having the includes without the linked library.
Related
I'm trying to build and run a project using tensorflow lite on my debian 11 intel x86_64 architecture. So far I've followed the official documentation and the official github example.
Here are the steps I've followed:
On ~/Desktop/ I ran git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
mkdir tflite_build & cd ~/Desktop/tflite_build
cmake ../tensorflow_src/tensorflow/lite
cmake --build . I've removed the -J flag regardless of what the docs says because it causes my pc to freeze.
mkdir ~/Desktop/tf_test & cd ~/Desktop/tf_test
Create a CMakeLists.txt and a main.cpp file inside tf_testdirectory.
Put the main code from the minimal example on the github repo provided above then this code in CMake:
cmake_minimum_required(VERSION 3.16)
project(minimal C CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTFLITE_DISABLE_TELEMETRY=1")
set(TENSORFLOW_SOURCE_DIR "" CACHE PATH
"Directory that contains the TensorFlow project" )
if(NOT TENSORFLOW_SOURCE_DIR)
get_filename_component(TENSORFLOW_SOURCE_DIR
"/home/user/Desktop/tensorflow_src" ABSOLUTE)
endif()
add_subdirectory(
"${TENSORFLOW_SOURCE_DIR}/tensorflow/lite"
"${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite" EXCLUDE_FROM_ALL)
add_executable(minimal minimal.cc)
target_link_libraries(minimal tensorflow-lite)
Created the folder tf_Test/build and ran cmake .. inside it.
After cmake is completed I run make inside the build directory and I'm getting the following error:
...
[100%] Linking CXX executable minimal
/usr/bin/ld: tensorflow-lite/libtensorflow-lite.a(interpreter.cc.o): in function `tflite::impl::Interpreter::ReportTelemetrySettings(char const*)':
interpreter.cc:(.text+0x292f): undefined reference to `tflite::telemetry::TelemetryReportSettings(TfLiteContext*, char const*, TfLiteTelemetryInterpreterSettings const*)'
/usr/bin/ld: tensorflow-lite/libtensorflow-lite.a(subgraph.cc.o): in function `tflite::Subgraph::Invoke()':
subgraph.cc:(.text+0x41c0): undefined reference to `tflite::telemetry::TelemetryReportEvent(TfLiteContext*, char const*, TfLiteStatus)'
/usr/bin/ld: tensorflow-lite/libtensorflow-lite.a(subgraph.cc.o): in function `tflite::Subgraph::ModifyGraphWithDelegate(TfLiteDelegate*)':
subgraph.cc:(.text+0x6ad0): undefined reference to `tflite::telemetry::TelemetryReportEvent(TfLiteContext*, char const*, TfLiteStatus)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/minimal.dir/build.make:184: minimal] Error 1
make[1]: *** [CMakeFiles/Makefile2:1408: CMakeFiles/minimal.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
Notice that it's not saying this for all the functions. For example this works std::unique_ptr<tflite::FlatBufferModel> model = tflite::FlatBufferModel::BuildFromFile(filename); without errors.
These tree are causing trouble: tflite::ops::builtin::BuiltinOpResolver resolver; std::unique_ptr<tflite::Interpreter> interpreter; tflite::InterpreterBuilder(*model, resolver)(&interpreter);
Note: I've trimmed some code compare to the github example for the sake of testing it, so only the above 4 lines are present on my main.
Why am I getting this error? I've tried compiling with bazel aswell but I'm getting the same error. What am I missing?
Probably it is missing from the CMakeLists file
Update CMakeLists.txt and add
tensorflow/lite/profiling/telemetry/telemetry.cc and
tensorflow/lite/profiling/telemetry/telemetry.h
to TFLITE_PROFILER_SRCS
It is also worth creating issue on Tensorflow repo for the team
In this time, I want to use Freeopcua to create a library to use in other project.
I have install all the tools in debian.soft file and build with following command sudo sh build.sh, cmake ., make, sudo make install. Although, in directory /usr/local/include and /usr/local/lib, there are opc directory and libopc*.so respectively, when I create a new cmake project, there is an error. Hope someone can help me or give some suggest. Thanks everyone~~~
I have refer to Libraries in /usr/local/lib not found, but it doesn't work for me
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(OPCUAIndependent)
include_directories(/usr/local/include/)
link_directories(/usr/local/lib/)
add_executable(sourceCode sourceCode.cpp)
target_link_libraries(sourceCode opc)
Error
[ 50%] Linking CXX executable sourceCode
/usr/bin/ld: cannot find -lopc
collect2: error: ld returned 1 exit status
CMakeFiles/sourceCode.dir/build.make:96: recipe for target 'sourceCode' failed
make[2]: *** [sourceCode] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/sourceCode.dir/all' failed
make[1]: *** [CMakeFiles/sourceCode.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
According to the Linux and macOS: Installation guide for Armadillo, on Debian machine(ubuntu-16.04) I was trying for installing the armadillo library and after executing the command : $cmake .
The full stop separated from "cmake" by a space is important.
I executed the command : $ make (also tried with root privileges still), the following error was thrown.
piyush#ubuntu:~/armadillo$ sudo make
Scanning dependencies of target armadillo
[ 33%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper1.cpp.o
[ 66%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper2.cpp.o
[100%] Linking CXX shared library libarmadillo.so
/usr/bin/ld: /usr/local/lib/libsuperlu.a(util.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libsuperlu.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
CMakeFiles/armadillo.dir/build.make:123: recipe for target 'libarmadillo.so.9.800.2' failed
make[2]: *** [libarmadillo.so.9.800.2] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/armadillo.dir/all' failed
make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
This library is available in Ubuntu. Just do
sudo apt install libarmadillo-dev
P.S. Never run sudo make, it's a very bad practice.
TL;DR When updating from CMake 3.10 to CMake 3.11.1 on archlinux, the following configuration line:
find_package(Boost COMPONENTS python3 COMPONENTS numpy3 REQUIRED)
leads to CMake linking against 3 different libraries
-- Boost version: 1.66.0
-- Found the following Boost libraries:
-- python3
-- numpy3
-- python
instead of the previous behaviour:
-- Boost version: 1.66.0
-- Found the following Boost libraries:
-- python3
-- numpy3
resulting in a linker error.
I use CMake to build a piece of software that relies on Boost python, and, since a couple of days ago, it seems that the line
find_package(Boost COMPONENTS numpy3 REQUIRED)
is no longer sufficient for CMake to understand that it should link the program against the Boost python3 library, and it uses the Boost library python instead.
Here is a minimal working example to reproduce what I am talking about.
test.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
}
CMakeList.txt
set(CMAKE_VERBOSE_MAKEFILE ON)
find_package(PythonLibs 3 REQUIRED)
find_package(Boost COMPONENTS numpy3 REQUIRED)
add_executable (test test.cpp)
target_link_libraries(test ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
With this configuration of CMake, a linker error will occur, and the error persists when I change the line adding numpy to
find_package(Boost COMPONENTS python3 COMPONENTS numpy3 REQUIRED)
Here is the result of cmake . && make:
/home/rastapopoulos/test $ cmake .
-- Boost version: 1.66.0
-- Found the following Boost libraries:
-- numpy3
-- python
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.11)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rastapopoulos/test
/home/rastapopoulos/test $ make
/usr/bin/cmake -H/home/rastapopoulos/test -B/home/rastapopoulos/test --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/rastapopoulos/test/CMakeFiles /home/rastapopoulos/test/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/rastapopoulos/test'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory '/home/rastapopoulos/test'
cd /home/rastapopoulos/test && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/rastapopoulos/test /home/rastapopoulos/test /home/rastapopoulos/test /home/rastapopoulos/test /home/rastapopoulos/test/CMakeFi
les/test.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/rastapopoulos/test'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory '/home/rastapopoulos/test'
[ 50%] Linking CXX executable test
/usr/bin/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/bin/c++ -rdynamic CMakeFiles/test.dir/test.o -o test -lboost_numpy3 -lboost_python -lpython3.6m
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyString_Size'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_FromEncodedObject'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyFile_FromString'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyString_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyInt_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyString_FromString'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyUnicodeUCS4_AsWideChar'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyString_FromStringAndSize'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `Py_InitModule4_64'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyString_FromFormat'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyNumber_Divide'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyNumber_InPlaceDivide'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyInt_AsLong'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyString_InternFromString'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyClass_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyString_AsString'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyInt_FromLong'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../lib/libboost_python.so: undefined reference to `PyFile_AsFile'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/test.dir/build.make:90: test] Error 1
make[2]: Leaving directory '/home/rastapopoulos/test'
make[1]: *** [CMakeFiles/Makefile2:71: CMakeFiles/test.dir/all] Error 2
make[1]: Leaving directory '/home/rastapopoulos/test'
make: *** [Makefile:87: all] Error 2
Has anyone experienced a similar problem and managed to solve it? I use cmake 3.11.1, boost 1.66.0-2, and run an updated version of Archlinux.
This bug is due to an invalid dependency description in FindBoost.cmake
set(_Boost_NUMPY_DEPENDENCIES python)
This has been fixed at https://github.com/Kitware/CMake/commit/c747d4ccb349f87963a8d1da69394bc4db6b74ed
Please use latest one, or you can rewrite it manually:
set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
CMake 3.10 does not properly support Boost 1.66. The Boost dependencies are hard-coded and if they chance, CMake has to adopt.
Delete the build directory and reconfigure. The configure step uses cached variables which prevents re-detection with the newer routines.
I am a beginner in OpenCV, using OpenCV 3.1.0 (downloaded from OpenCV.org) with Mac OS X 10.9.5.
I was trying to run a code which needs contrib.hpp, then I found the extra modules from Github. There is a command from the page:
$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5
Everything was successful before I did make, it shows an error of no matching function for call to 'calibrateCamera' :
[ 92%] Building CXX object modules/aruco/CMakeFiles/opencv_aruco.dir/src/aruco.cpp.o
/Users/Youko/downloads/opencv_contrib-master/modules/aruco/src/aruco.cpp:1583:12: error:
no matching function for call to 'calibrateCamera'
return calibrateCamera(processedObjectPoints, processedImagePoints, ...
^~~~~~~~~~~~~~~
/Users/Youko/downloads/opencv-3.1.0/modules/calib3d/include/opencv2/calib3d.hpp:844:21: note:
candidate function not viable: requires at most 9 arguments, but 12 were
provided
CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints,
^
1 error generated.
make[2]: *** [modules/aruco/CMakeFiles/opencv_aruco.dir/src/aruco.cpp.o] Error 1
make[1]: *** [modules/aruco/CMakeFiles/opencv_aruco.dir/all] Error 2
make: *** [all] Error 2
In the case of I wanna keep the version of Mac OSX, I was thinking of change the version of OpenCV, so I've downloaded OpenCV from Github, and tried to install the OpenCV with following command (it was the same way as how I've installed OpenCV 3.1.0 successfully):
$ cd <opencv_source_directory>
$ mkdir release
$ cd release
$ cmake -G "Unix Makefiles" ..
$ make
$ sudo make install
But there is another problem when I tried make:
[ 44%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_decoder.cpp.o
[ 44%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_avfoundation_mac.mm.o
[ 44%] Linking CXX shared library ../../lib/libopencv_videoio.dylib
ld: framework not found CoreImage
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_videoio.3.1.0.dylib] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
I thought maybe there was something wrong with cmake, so I tried the following command as well but the same error occurred with make:
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
I've googled for the problem and it seems like I must need the QuartzCore, but most of people said it should be included in the Xcode (I am using Xcode 6.2 btw). I tried both ways to figure it out but I still have no idea why I can't build the extra modules. (I think the most weird problem is that I cannot install OpenCV cloned from Github, but I just wanna show I tried this way but it wasn't successful FYI.)
I'd be most grateful for any help and suggestions!