bin/example_reg_map_test error in opencv - python-3.x

I am getting following error while openCV environment setup on my ubuntu 18.04. I have execute some commands which are related to libraries which is require then I have executed following one and shows error
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
and then following error occurs. Please check this and give solution if you have. Thanks in advance.
[ 30%] Built target opencv_photo
[ 30%] Built target opencv_plot
[ 31%] Built target opencv_imgcodecs
[ 32%] Built target opencv_reg
[ 32%] Built target opencv_xphoto
[ 32%] Built target opencv_video
[ 32%] Built target opencv_freetype
[ 35%] Built target opencv_dnn
[ 35%] Built target opencv_hfs
[ 35%] Built target opencv_fuzzy
[ 36%] Built target opencv_img_hash
[ 36%] Built target opencv_xobjdetect
[ 36%] Built target opencv_shape
[ 37%] Built target opencv_videoio
[ 38%] Built target opencv_face
[ 38%] Built target opencv_superres
[ 38%] Built target opencv_highgui
[ 38%] Built target example_hdf_read_write_attributes
[ 38%] Built target example_hdf_create_groups
[ 38%] Built target example_hdf_create_read_write_datasets
[ 39%] Built target opencv_ts
Scanning dependencies of target example_reg_map_test
Scanning dependencies of target example_surface_matching_ppf_load_match
[ 39%] Linking CXX executable ../../bin/example_phase_unwrapping_unwrap
[ 39%] Linking CXX executable ../../bin/example_plot_plot_demo
[ 39%] Building CXX object modules/reg/CMakeFiles/example_reg_map_test.dir/samples/map_test.cpp.o
[ 39%] Building CXX object modules/surface_matching/CMakeFiles/example_surface_matching_ppf_load_match.dir/samples/ppf_load_match.cpp.o
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadRGBAStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadDirectory#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteEncodedStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFIsTiled#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteScanline#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `_TIFFfree#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFGetField#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFNumberOfStrips#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFScanlineSize#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteDirectory#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadEncodedTile#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadRGBATile#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFClose#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFClientOpen#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFRGBAImageOK#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFOpen#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadEncodedStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetField#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetWarningHandler#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetErrorHandler#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `_TIFFmalloc#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadScanline#LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
modules/phase_unwrapping/CMakeFiles/example_phase_unwrapping_unwrap.dir/build.make:100: recipe for target 'bin/example_phase_unwrapping_unwrap' failed
make[2]: *** [bin/example_phase_unwrapping_unwrap] Error 1
CMakeFiles/Makefile2:4625: recipe for target 'modules/phase_unwrapping/CMakeFiles/example_phase_unwrapping_unwrap.dir/all' failed
make[1]: *** [modules/phase_unwrapping/CMakeFiles/example_phase_unwrapping_unwrap.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadRGBAStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadDirectory#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteEncodedStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFIsTiled#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteScanline#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `_TIFFfree#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFGetField#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFNumberOfStrips#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFScanlineSize#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteDirectory#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadEncodedTile#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadRGBATile#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFClose#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFClientOpen#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFRGBAImageOK#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFOpen#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadEncodedStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetField#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetWarningHandler#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetErrorHandler#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `_TIFFmalloc#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadScanline#LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
modules/plot/CMakeFiles/example_plot_plot_demo.dir/build.make:100: recipe for target 'bin/example_plot_plot_demo' failed
make[2]: *** [bin/example_plot_plot_demo] Error 1
CMakeFiles/Makefile2:5165: recipe for target 'modules/plot/CMakeFiles/example_plot_plot_demo.dir/all' failed
make[1]: *** [modules/plot/CMakeFiles/example_plot_plot_demo.dir/all] Error 2
[ 39%] Linking CXX executable ../../bin/example_surface_matching_ppf_load_match
[ 39%] Built target example_surface_matching_ppf_load_match
[ 39%] Linking CXX executable ../../bin/example_reg_map_test
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadRGBAStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadDirectory#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteEncodedStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFIsTiled#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteScanline#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `_TIFFfree#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFGetField#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFNumberOfStrips#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFScanlineSize#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFWriteDirectory#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadEncodedTile#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadRGBATile#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFClose#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFClientOpen#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFRGBAImageOK#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFOpen#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadEncodedStrip#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetField#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetWarningHandler#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFSetErrorHandler#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `_TIFFmalloc#LIBTIFF_4.0'
../../lib/libopencv_imgcodecs.so.3.4.1: undefined reference to `TIFFReadScanline#LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
modules/reg/CMakeFiles/example_reg_map_test.dir/build.make:100: recipe for target 'bin/example_reg_map_test' failed
make[2]: *** [bin/example_reg_map_test] Error 1
CMakeFiles/Makefile2:5650: recipe for target 'modules/reg/CMakeFiles/example_reg_map_test.dir/all' failed
make[1]: *** [modules/reg/CMakeFiles/example_reg_map_test.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

It's opencv version and installation problem in ubuntu. Now i have followed following instruction and it's works perfectly.
https://www.learnopencv.com/install-opencv3-on-ubuntu

Related

CMake build: undefined reference to libdrm

I tried to write a demo program of drm, but I encountered undefined reference to problems:
xjt#u16:~/SF6_RV1126/drmDemo/build$ make -j8
Scanning dependencies of target drmDemo
[ 50%] Building C object bin/CMakeFiles/drmDemo.dir/main.c.o
[100%] Linking C executable drmDemo
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/drmDemo.dir/main.c.o: in function `modeset_create_fb':
main.c:(.text+0x6c): undefined reference to `drmIoctl'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.c:(.text+0xe0): undefined reference to `drmModeAddFB'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.c:(.text+0x100): undefined reference to `drmIoctl'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/drmDemo.dir/main.c.o: in function `modeset_destroy_fb':
main.c:(.text+0x194): undefined reference to `drmModeRmFB'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.c:(.text+0x1d4): undefined reference to `drmIoctl'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: CMakeFiles/drmDemo.dir/main.c.o: in function `main':
main.c:(.text+0x214): undefined reference to `drmModeGetResources'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.c:(.text+0x248): undefined reference to `drmModeGetConnector'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.c:(.text+0x2d4): undefined reference to `drmModeSetCrtc'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.c:(.text+0x2f0): undefined reference to `drmModeFreeConnector'
/home/xjt/SF6_RV1126/RV1126/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: main.c:(.text+0x2f8): undefined reference to `drmModeFreeResources'
collect2: error: ld returned 1 exit status
bin/CMakeFiles/drmDemo.dir/build.make:94: recipe for target 'bin/drmDemo' failed
make[2]: *** [bin/drmDemo] Error 1
CMakeFiles/Makefile2:85: recipe for target 'bin/CMakeFiles/drmDemo.dir/all' failed
make[1]: *** [bin/CMakeFiles/drmDemo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
my cc tool chain is arm-linux-gnueabihf- whic is produced from Buildroot. And I use CMake to build my program. Here is my project tree:
.
├── CMakeLists.txt # 1
├── src
│ ├── main.c
│ └── CMakeLists.txt # 2
└── build
in CML1:
PROJECT(RV1126)
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
SET(CMAKE_C_COMPILER "/home/xjt/SF6_RV1126/RV1126/buildroot/output/rockchip_rv1126_rv1109_dcir/host/bin/arm-linux-gnueabihf-gcc")
ADD_SUBDIRECTORY(src bin)
in CML2:
SET(
SRC_LIST
main.c
)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR/bin})
ADD_EXECUTABLE(drmDemo ${SRC_LIST})
I guess it's a linking problem, how should I modify CMake to link to libdrm?
As #Tsyvarev said, after ADD_EXECUTABLE() add LINK_LIBRARIES("....../lib/libdrm.so ") and TARGET_LINK_LIBRARIES(demo libdrm.so). Thanks again #Tsyvarev.

Include mongocxx drivers with Cmake results with undefined methods on Ubuntu

I have an issue with linking libmongocxx in my project.
I am using CMAKE to link the library and I am running Ubuntu 17.10.
Here is my CMakeLists.txt :
cmake_minimum_required(VERSION 3.9)
project(web_service_cpp)
SET(CMAKE_CXX_STANDARD 14)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
find_package(Boost REQUIRED)
find_package(Hana REQUIRED)
find_package(libmongocxx REQUIRED)
find_package(libbsoncxx REQUIRED)
add_library(libmongocxx INTERFACE IMPORTED)
set_property(TARGET libmongocxx PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${libmongocxx_INCLUDE_DIR})
add_library(boost INTERFACE IMPORTED)
set_property(TARGET boost PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR})
include_directories(${LIBMONGOCXX_INCLUDE_DIR})
include_directories(${LIBBSONCXX_INCLUDE_DIR})
include_directories("/usr/local/include/mongocxx/v_noabi")
include_directories("/usr/local/include/bsoncxx/v_noabi")
include_directories("/usr/local/include/libmongoc-1.0")
include_directories("/usr/local/include/libbson-1.0")
include_directories("/usr/local/lib")
include_directories("${PROJECT_SOURCE_DIR}")
set(SOURCE_FILES src/main.cpp
src/cMqttService.cpp
src/cMongoDB.cpp
src/cRepository.cpp)
set(HEADER_FILES include/cRepository.h
include/cMqttService.h
include/cMongoDB.h
include/main.h)
add_executable(web_service_cpp
${HEADER_FILES}
${SOURCE_FILES})
target_link_libraries(web_service_cpp ${LIBMONGOCXX_LIBRARIES})
target_link_libraries(web_service_cpp ${LIBBSONXX_LiBRARIES})
I find it weird that I am getting this error since it use to work on macOS :
[ 20%] Building CXX object
CMakeFiles/web_service_cpp.dir/src/main.cpp.o
[ 40%] Building CXX object CMakeFiles/web_service_cpp.dir/src/cMqttService.cpp.o
[ 60%] Building CXX object CMakeFiles/web_service_cpp.dir/src/cMongoDB.cpp.o
[ 80%] Building CXX object CMakeFiles/web_service_cpp.dir/src/cRepository.cpp.o
[100%] Linking CXX executable bin/bin/web_service_cpp
CMakeFiles/web_service_cpp.dir/src/cMqttService.cpp.o: In function `cMqttService::initCommunication()':
cMqttService.cpp:(.text+0x1da): undefined reference to `mqtt::async_client::async_client(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, mqtt::iclient_persistence*)'
cMqttService.cpp:(.text+0x225): undefined reference to `mqtt::connect_options::connect_options()'
cMqttService.cpp:(.text+0x266): undefined reference to `mqtt::connect_options::connect_options(mqtt::connect_options const&)'
cMqttService.cpp:(.text+0x286): undefined reference to `mqtt::async_client::connect(mqtt::connect_options)'
cMqttService.cpp:(.text+0x3ca): undefined reference to `mqtt::async_client::publish(std::shared_ptr)'
cMqttService.cpp:(.text+0x464): undefined reference to `mqtt::async_client::publish(mqtt::buffer_ref, void const*, unsigned long, int, bool)'
cMqttService.cpp:(.text+0x4ea): undefined reference to `mqtt::async_client::~async_client()'
cMqttService.cpp:(.text+0x63f): undefined reference to `mqtt::async_client::~async_client()'
CMakeFiles/web_service_cpp.dir/src/cMqttService.cpp.o: In function `mqtt::async_client::disconnect()':
cMqttService.cpp:(.text._ZN4mqtt12async_client10disconnectEv[_ZN4mqtt12async_client10disconnectEv]+0x36): undefined reference to `mqtt::disconnect_options::disconnect_options()'
CMakeFiles/web_service_cpp.dir/src/cMqttService.cpp.o: In function `void __gnu_cxx::new_allocator::construct, mqtt::buffer_ref, int&, bool&>(mqtt::message*, mqtt::buffer_ref&&, mqtt::buffer_ref&&, int&, bool&)':
cMqttService.cpp:(.text._ZN9__gnu_cxx13new_allocatorIN4mqtt7messageEE9constructIS2_JNS1_10buffer_refIcEES6_RiRbEEEvPT_DpOT0_[_ZN9__gnu_cxx13new_allocatorIN4mqtt7messageEE9constructIS2_JNS1_10buffer_refIcEES6_RiRbEEEvPT_DpOT0_]+0xdc): undefined reference to `mqtt::message::message(mqtt::buffer_ref, mqtt::buffer_ref, int, bool)'
CMakeFiles/web_service_cpp.dir/src/cMongoDB.cpp.o: In function `cMongoDB::cMongoDB(std::__cxx11::basic_string, std::allocator >, short)':
cMongoDB.cpp:(.text+0x63): undefined reference to `mongocxx::v_noabi::instance::instance()'
cMongoDB.cpp:(.text+0x7c): undefined reference to `mongocxx::v_noabi::uri::k_default_uri[abi:cxx11]'
cMongoDB.cpp:(.text+0x96): undefined reference to `mongocxx::v_noabi::uri::uri(bsoncxx::v_noabi::string::view_or_value)'
cMongoDB.cpp:(.text+0xb8): undefined reference to `mongocxx::v_noabi::client::client()'
cMongoDB.cpp:(.text+0x190): undefined reference to `mongocxx::v_noabi::uri::uri(bsoncxx::v_noabi::string::view_or_value)'
cMongoDB.cpp:(.text+0x1ad): undefined reference to `mongocxx::v_noabi::uri::operator=(mongocxx::v_noabi::uri&&)'
cMongoDB.cpp:(.text+0x1bc): undefined reference to `mongocxx::v_noabi::uri::~uri()'
cMongoDB.cpp:(.text+0x215): undefined reference to `mongocxx::v_noabi::client::client(mongocxx::v_noabi::uri const&, mongocxx::v_noabi::options::client const&)'
cMongoDB.cpp:(.text+0x232): undefined reference to `mongocxx::v_noabi::client::operator=(mongocxx::v_noabi::client&&)'
cMongoDB.cpp:(.text+0x241): undefined reference to `mongocxx::v_noabi::client::~client()'
cMongoDB.cpp:(.text+0x2e3): undefined reference to `mongocxx::v_noabi::client::~client()'
cMongoDB.cpp:(.text+0x2f6): undefined reference to `mongocxx::v_noabi::uri::~uri()'
cMongoDB.cpp:(.text+0x309): undefined reference to `mongocxx::v_noabi::instance::~instance()'
collect2: error: ld returned 1 exit status
CMakeFiles/web_service_cpp.dir/build.make:172: recipe for target 'bin/bin/web_service_cpp' failed
make[2]: *** [bin/bin/web_service_cpp] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/web_service_cpp.dir/all' failed
make[1]: *** [CMakeFiles/web_service_cpp.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I am open to suggestions!
Thank you for your help in advance.
I found the solution to my problem. It is caused by all those hard coded strings that I used back on macOS.
cmake_minimum_required(VERSION 3.9)
project(web_service_cpp)
SET(CMAKE_CXX_STANDARD 14)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
find_package(Boost REQUIRED)
find_package(Hana REQUIRED)
find_package(OpenSSL REQUIRED)
find_library(paho-mqttpp3 NAMES libpaho-mqttpp3.so REQUIRED)
find_library(paho-mqtt3a NAMES libpaho-mqtt3a.so REQUIRED)
find_package(libmongocxx REQUIRED)
find_package(libbsoncxx REQUIRED)
add_library(libmongocxx INTERFACE IMPORTED)
add_library(libbsoncxx INTERFACE IMPORTED)
set_property(TARGET libmongocxx PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${LIBMONGOCXX_INCLUDE_DIRS})
set_property(TARGET libbsoncxx PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${LIBBSONCXX_INCLUDE_DIRS})
add_library(boost INTERFACE IMPORTED)
set_property(TARGET boost PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR})
add_library(pahottpp STATIC IMPORTED)
set_target_properties(pahottpp PROPERTIES IMPORTED_LOCATION ${paho-mqttpp3})
add_library(pahomqtt3a SHARED IMPORTED)
set_property(TARGET pahomqtt3a PROPERTY IMPORTED_LOCATION ${paho-mqtt3a})
include_directories(${LIBMONGOCXX_INCLUDE_DIRS} ${LIBBSONCXX_INCLUDE_DIRS})
link_directories(${LIBMONGOCXX_INCLUDE_DIRS})
link_directories(${LIBBSONCXX_INCLUDE_DIR})
include_directories("${PROJECT_SOURCE_DIR}")
set(SOURCE_FILES src/main.cpp
src/cMqttService.cpp
src/cMongoDB.cpp
src/cRepository.cpp)
set(HEADER_FILES include/cRepository.h
include/cMqttService.h
include/cMongoDB.h
include/main.h)
add_executable(web_service_cpp
${HEADER_FILES}
${SOURCE_FILES})
target_link_libraries(web_service_cpp ${LIBMONGOCXX_LIBRARIES} ${lIBBSONCXX_LIBRARIES} pahottpp pahomqtt3a)

Compilation of MAX_HS solver with IBM CPLEX

i'm trying to get started with a max-sat solver named: MAX_HS.
The documentation is only a readme file, is not so much but it's clear what you have to do:
https://github.com/fbacchus/MaxHS
I've installed CPLEX library from IBM and configured the file as indicated in the documentation, but when I compile i'm getting an error, this is my terminal log:
\\install -d /usr/local/include/maxhs
install -d /usr/local/include/minisat
for dir in maxhs/core maxhs/ifaces maxhs/ds maxhs/utils; do \
install -d /usr/local/include/$dir ; \
done
for dir in minisat/mtl minisat/utils minisat/core minisat/simp; do \
install -d /usr/local/include/$dir ; \
done
for h in minisat/mtl/Alg.h minisat/mtl/Map.h minisat/mtl/Alloc.h minisat/mtl/Vec.h minisat/mtl/Rnd.h minisat/mtl/Sort.h minisat/mtl/IntMap.h minisat/mtl/Queue.h minisat/mtl/IntTypes.h minisat/mtl/Heap.h minisat/mtl/XAlloc.h minisat/core/SolverTypes.h minisat/core/Dimacs.h minisat/core/Solver.h minisat/utils/System.h minisat/utils/ParseUtils.h
minisat/utils/Options.h minisat/simp/SimpSolver.h ;
do \
install -m 644 $h /usr/local/include/$h ; \
done
for h in maxhs/core/Bvars.h maxhs/core/Dimacs.h maxhs/core/MaxSolverTypes.h maxhs/core/Assumptions.h maxhs/core/Wcnf.h maxhs/core/MaxSolver.h maxhs/ifaces/miniSatSolver.h maxhs/ifaces/GreedySolver.h maxhs/ifaces/Cplex.h maxhs/ifaces/greedySatSolver.h maxhs/ifaces/muser.h maxhs/ifaces/SatSolver.h maxhs/ds/Packed.h maxhs/utils/io.h maxhs/utils/Params.h maxhs/utils/hash.h ;
do \
install -m 644 $h /usr/local/include/$h ; \
done
install -d /usr/local/lib
install -m 644 build/release/lib/libmaxhs.a /usr/local/lib
Linking Binary: build/release/bin/maxhs
/opt/ibm/ILOG/CPLEX_Studio128/cplex/lib/x86-64_linux/static_pic/libcplex.a(mkl_memory_patched.o): In function `mkl_serv_set_memory_limit':
mkl_memory.c:(.text+0x5a9): undefined reference to `dlopen'
mkl_memory.c:(.text+0x5ca): undefined reference to `dlsym'
mkl_memory.c:(.text+0x618): undefined reference to `dlsym'
mkl_memory.c:(.text+0x62e): undefined reference to `dlsym'
mkl_memory.c:(.text+0x644): undefined reference to `dlsym'
mkl_memory.c:(.text+0x739): undefined reference to `dlerror'
mkl_memory.c:(.text+0x78c): undefined reference to `dlopen'
mkl_memory.c:(.text+0x840): undefined reference to `dlopen'
mkl_memory.c:(.text+0x856): undefined reference to `dlerror'
mkl_memory.c:(.text+0x91a): undefined reference to `dlopen'
mkl_memory.c:(.text+0x922): undefined reference to `dlerror'
mkl_memory.c:(.text+0x937): undefined reference to `dlsym'
mkl_memory.c:(.text+0x95a): undefined reference to `dlopen'
mkl_memory.c:(.text+0x962): undefined reference to `dlerror'
mkl_memory.c:(.text+0x972): undefined reference to `dlsym'
mkl_memory.c:(.text+0x98d): undefined reference to `dlerror'
...
...
...
64_linux/static_pic/libcplex.a(mkl_semaphore.o): In function `_Init_MKL_Loader':
mkl_semaphore.c:(.text+0x4ed): undefined reference to `dladdr'
/opt/ibm/ILOG/CPLEX_Studio128/cplex/lib/x86-64_linux/static_pic/libcplex.a(libc_is_static_interface.o): In function `mkl_serv_libc_is_static':
libc_is_static_interface.c:(.text+0x10): undefined reference to `dladdr'
/opt/ibm/ILOG/CPLEX_Studio128/cplex/lib/x86-64_linux/static_pic/libcplex.a(load_library_HOST.o): In function `mkl_ueaa_prv_load_backend_lib':
load_library.c:(.text+0x1cd): undefined reference to `dlopen'
load_library.c:(.text+0x1ef): undefined reference to `dlvsym'
load_library.c:(.text+0x218): undefined reference to `dlvsym'
load_library.c:(.text+0x241): undefined reference to `dlvsym'
load_library.c:(.text+0x26a): undefined reference to `dlvsym'
load_library.c:(.text+0x293): undefined reference to `dlvsym'
/opt/ibm/ILOG/CPLEX_Studio128/cplex/lib/x86-64_linux/static_pic/libcplex.a(load_library_HOST.o):load_library.c:(.text+0x2bc): more undefined references to `dlvsym' follow
/opt/ibm/ILOG/CPLEX_Studio128/cplex/lib/x86-64_linux/static_pic/libcplex.a(mkl_aa_fw_load_orsl_lite_lib_HOST.o): In function `mkl_aa_fw_load_orsl_lite_lib':
mkl_aa_fw_load_orsl_lite_lib.c:(.text+0xb9): undefined reference to `dlopen'
mkl_aa_fw_load_orsl_lite_lib.c:(.text+0xd4): undefined reference to `dlsym'
mkl_aa_fw_load_orsl_lite_lib.c:(.text+0xf2): undefined reference to `dlsym'
mkl_aa_fw_load_orsl_lite_lib.c:(.text+0x110): undefined reference to `dlsym'
mkl_aa_fw_load_orsl_lite_lib.c:(.text+0x12e): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
Makefile:155: recipe for target 'build/release/bin/maxhs' failed
make: *** [build/release/bin/maxhs] Error 1
Really don't know what can cause the error as the library are the official licensed IBM cplex library and the only setup is the one who assign the right path to the IBM library. I guess i've done correctly this step as when the path was wrong and no IBM library was found i was getting another error.
Any ideas?
Thank you!
With CPLEX 12.8 you have to link with the dynamic linker library. You can see this in the example makefiles shipped with CPLEX. Looking at the Makefile in the MaxHS git repository, you could try changing the following line (this has not been tested):
MAXHS_LDFLAGS = -Wall -lz -L$(CPLEXLIBDIR) -lcplex -lpthread
to:
MAXHS_LDFLAGS = -Wall -lz -L$(CPLEXLIBDIR) -lcplex -lpthread -ldl
If that works, you should consider creating an issue for the maintainers of MaxHS.
Alternately, you could install an older version of CPLEX (e.g., 12.7.1).

Error while compiling gdb

I get the following error when compiling GDB.
../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -ldl -ltermcap -lz -lm -L/usr/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -lexpat ../libiberty/libiberty.a build-gnulib/import/libgnu.a
python.o: In function `gdbpy_target_charset':
python.c:(.text+0x7b5): undefined reference to `PyUnicodeUCS2_Decode'
python.o: In function `gdbpy_target_wide_charset':
python.c:(.text+0x820): undefined reference to `PyUnicodeUCS2_Decode'
py-cmd.o: In function `cmdpy_function':
py-cmd.c:(.text+0x39b): undefined reference to `PyUnicodeUCS2_Decode'
py-cmd.o: In function `cmdpy_completer':
py-cmd.c:(.text+0x74c): undefined reference to `PyUnicodeUCS2_Decode'
py-cmd.c:(.text+0x7c0): undefined reference to `PyUnicodeUCS2_Decode'
py-frame.o:py-frame.c:(.text+0x29b): more undefined references to `PyUnicodeUCS2_Decode' follow
py-utils.o: In function `python_string_to_unicode':
py-utils.c:(.text+0xe1): undefined reference to `PyUnicodeUCS2_FromEncodedObject'
py-utils.o: In function `unicode_to_encoded_string':
py-utils.c:(.text+0x13c): undefined reference to `PyUnicodeUCS2_AsEncodedString'
py-utils.o: In function `unicode_to_encoded_python_string':
py-utils.c:(.text+0x1c7): undefined reference to `PyUnicodeUCS2_AsEncodedString'
py-utils.o: In function `target_string_to_unicode':
py-utils.c:(.text+0x409): undefined reference to `PyUnicodeUCS2_Decode'
py-value.o: In function `valpy_string':
py-value.c:(.text+0xb8b): undefined reference to `PyUnicodeUCS2_Decode'
py-value.o: In function `valpy_str':
py-value.c:(.text+0x141b): undefined reference to `PyUnicodeUCS2_Decode'
collect2: ld returned 1 exit status
make[2]: *** [gdb] Error 1
make[2]: Leaving directory
What might be the reason for it?

static link openssl to sqlcipher

I have build sqlcipher for Linux but it depends on openssl. I want to configure sqlcipher to work without external openssl library by linking it statically.
I configure sqlcipher with this command
./configure --prefix=/home/admin/Downloads/qt-everywhere-opensource-src-4.8.0/src/plugins/sqldrivers/sqlcipher/ --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="/usr/lib64/libcrypto.a"
make
after that I got next strings:
/libtool --mode=link gcc -DSQLITE_HAS_CODEC -DSQLITE_OS_UNIX=1 -I. -I./src -I./ext/rtree -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/usr/include -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 /usr/lib64/libcrypto.a -DHAVE_READLINE=0 \
-o sqlite3 ./src/shell.c libsqlite3.la \
-lpthread -rpath "/home/admin/Downloads/qt-everywhere-opensource-src-4.8.0/src/plugins/sqldrivers/sqlcipher/lib"
libtool: link: gcc -DSQLITE_HAS_CODEC -DSQLITE_OS_UNIX=1 -I. -I./src -I./ext/rtree -D_HAVE_SQLITE_CONFIG_H -DNDEBUG -I/usr/include -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DHAVE_READLINE=0 -o sqlite3 ./src/shell.c /usr/lib64/libcrypto.a ./.libs/libsqlite3.a -lpthread -Wl,-rpath -Wl,/home/admin/Downloads/qt-everywhere-opensource-src-4.8.0/src/plugins/sqldrivers/sqlcipher/lib
./.libs/libsqlite3.a(sqlite3.o): In function `sqlcipher_activate':
sqlite3.c:(.text+0xb66): undefined reference to `EVP_get_cipherbyname'
sqlite3.c:(.text+0xb70): undefined reference to `OPENSSL_add_all_algorithms_noconf'
./.libs/libsqlite3.a(sqlite3.o): In function `sqlcipher_random':
sqlite3.c:(.text+0xc0c): undefined reference to `RAND_bytes'
./.libs/libsqlite3.a(sqlite3.o): In function `sqlcipher_codec_ctx_set_cipher':
sqlite3.c:(.text+0x11a2): undefined reference to `EVP_get_cipherbyname'
sqlite3.c:(.text+0x11ba): undefined reference to `EVP_CIPHER_key_length'
sqlite3.c:(.text+0x11d4): undefined reference to `EVP_CIPHER_iv_length'
sqlite3.c:(.text+0x11ee): undefined reference to `EVP_CIPHER_block_size'
sqlite3.c:(.text+0x11fd): undefined reference to `EVP_sha1'
sqlite3.c:(.text+0x1205): undefined reference to `EVP_MD_size'
./.libs/libsqlite3.a(sqlite3.o): In function `sqlcipher_page_hmac':
sqlite3.c:(.text+0x1880): undefined reference to `HMAC_CTX_init'
sqlite3.c:(.text+0x1885): undefined reference to `EVP_sha1'
sqlite3.c:(.text+0x18b9): undefined reference to `HMAC_Init_ex'
sqlite3.c:(.text+0x18d9): undefined reference to `HMAC_Update'
sqlite3.c:(.text+0x18f8): undefined reference to `HMAC_Update'
sqlite3.c:(.text+0x1917): undefined reference to `HMAC_Final'
sqlite3.c:(.text+0x1929): undefined reference to `HMAC_CTX_cleanup'
./.libs/libsqlite3.a(sqlite3.o): In function `sqlcipher_page_cipher':
sqlite3.c:(.text+0x1b35): undefined reference to `EVP_CipherInit'
sqlite3.c:(.text+0x1b4a): undefined reference to `EVP_CIPHER_CTX_set_padding'
sqlite3.c:(.text+0x1b7a): undefined reference to `EVP_CipherInit'
sqlite3.c:(.text+0x1ba2): undefined reference to `EVP_CipherUpdate'
sqlite3.c:(.text+0x1bcc): undefined reference to `EVP_CipherFinal'
sqlite3.c:(.text+0x1be2): undefined reference to `EVP_CIPHER_CTX_cleanup'
./.libs/libsqlite3.a(sqlite3.o): In function `sqlcipher_cipher_ctx_key_derive':
sqlite3.c:(.text+0x1d3a): undefined reference to `PKCS5_PBKDF2_HMAC_SHA1'
sqlite3.c:(.text+0x1e08): undefined reference to `PKCS5_PBKDF2_HMAC_SHA1'
collect2: ld returned 1 exit status
make: *** [sqlite3] Error 1
I have installed openssl and openssl-dev packages and /usr/lib64/libcrypto.a exists.
What I do wrong?
Adjust your CFLAGS to include the path to the OpenSSL header files. Something like this:
CFLAGS="-DSQLITE_HAS_CODEC -I/path/to/openssl/include"

Resources