I have a executable:
add_executable(treshhold src/main.cpp)
add_dependencies(treshhold ${PROJECT_NAME})
I have a directory
/opt/halcon/lib/x64-linux
which contains multiple .so files:
hAcqArgos3D-P1xx.so hAcqGigEVision.so hAcqMatrixVisionAcquire.so hAcquEye.so hioOPC_UA.so libhalconcpp.so libhalcon.so libhdevenginecpp.so
hAcqArgos3D-P1xxxl.so hAcqGigEVisionxl.so hAcqMatrixVisionAcquirexl.so hAcquEyexl.so hioOPC_UAxl.so libhalconcppxl.so libhalconxl.so libhdevenginecppxl.so
hAcqFile.so hAcqLPS36.so hAcqO3D3xx.so hAcqVideo4Linux2.so libhalconcpp10.so libhalconc.so libhdevenginecpp10.so libuastack.so
hAcqFilexl.so hAcqLPS36xl.so hAcqO3D3xxxl.so hAcqVideo4Linux2xl.so libhalconcpp10xl.so libhalconcxl.so libhdevenginecpp10xl.so libusb-1.0-usan.so.0
linked used using and tried both:
include_directories(/opt/halcon/lib/x64-linux)
link_directories(/opt/halcon/lib/x64-linux)
But when i try a to link a certain library
target_link_libraries(treshhold libhalconc)
i get the error:
[ 50%] Linking CXX executable treshhold
/usr/bin/ld: cannot find -llibhalconc
And if i try not to make the target link i get the missing reference error from the compiler.
EDIT Full file:
cmake_minimum_required(VERSION 2.8.3)
project(ros_halcon_bridge)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
add_executable(treshhold src/main.cpp)
add_dependencies(treshhold ${PROJECT_NAME})
include_directories(/opt/halcon/lib/x64-linux)
link_directories(/opt/halcon/lib/x64-linux)
target_link_libraries(treshhold libhalconc)
EDIT2
I would want to add all libraries with the following:
target_link_libraries(treshhold hAcqArgos3D-P1xx.so hAcqGigEVision.so hAcqMatrixVisionAcquire.so hAcquEye.so hioOPC_UA.so libhalconcpp.so libhalcon.so libhdevenginecpp.so hAcqArgos3D-P1xxxl.so hAcqGigEVisionxl.so hAcqMatrixVisionAcquirexl.so hAcquEyexl.so hioOPC_UAxl.so libhalconcppxl.so libhalconxl.so libhdevenginecppxl.so hAcqFile.so hAcqLPS36.so hAcqO3D3xx.so hAcqVideo4Linux2.so libhalconcpp10.so libhalconc.so libhdevenginecpp10.so libuastack.so hAcqFilexl.so hAcqLPS36xl.so hAcqO3D3xxxl.so hAcqVideo4Linux2xl.so libhalconcpp10xl.so libhalconcxl.so libhdevenginecpp10xl.so libusb-1.0-usan.so.0)
but that results in:
[ 50%] Linking CXX executable treshhold
/usr/bin/ld: cannot find -lhAcqArgos3D-P1xx
/usr/bin/ld: cannot find -lhAcqGigEVision
/usr/bin/ld: cannot find -lhAcqMatrixVisionAcquire
/usr/bin/ld: cannot find -lhAcquEye
/usr/bin/ld: cannot find -lhioOPC_UA
/usr/bin/ld: cannot find -lhalconcpp
/usr/bin/ld: cannot find -lhalcon
/usr/bin/ld: cannot find -lhdevenginecpp
/usr/bin/ld: cannot find -lhAcqArgos3D-P1xxxl
/usr/bin/ld: cannot find -lhAcqGigEVisionxl
/usr/bin/ld: cannot find -lhAcqMatrixVisionAcquirexl
/usr/bin/ld: cannot find -lhAcquEyexl
/usr/bin/ld: cannot find -lhioOPC_UAxl
/usr/bin/ld: cannot find -lhalconcppxl
/usr/bin/ld: cannot find -lhalconxl
/usr/bin/ld: cannot find -lhdevenginecppxl
/usr/bin/ld: cannot find -lhAcqFile
/usr/bin/ld: cannot find -lhAcqLPS36
/usr/bin/ld: cannot find -lhAcqO3D3xx
/usr/bin/ld: cannot find -lhAcqVideo4Linux2
/usr/bin/ld: cannot find -lhalconcpp10
/usr/bin/ld: cannot find -lhalconc
/usr/bin/ld: cannot find -lhdevenginecpp10
/usr/bin/ld: cannot find -luastack
/usr/bin/ld: cannot find -lhAcqFilexl
/usr/bin/ld: cannot find -lhAcqLPS36xl
/usr/bin/ld: cannot find -lhAcqO3D3xxxl
/usr/bin/ld: cannot find -lhAcqVideo4Linux2xl
/usr/bin/ld: cannot find -lhalconcpp10xl
/usr/bin/ld: cannot find -lhalconcxl
/usr/bin/ld: cannot find -lhdevenginecpp10xl
/usr/bin/ld: cannot find -lusb-1.0-usan
You can see what CMake is doing with
make VERBOSE=1
Then you should be able to find out what's wrong with the generated command.
Only once you're sure about the command you really want should you bother with how to write it correctly with cmake
Related
I have been trying very hard to set up OpenVINO for my C++ programme. But the official guide was very unclear to me (partially because I am a very beginner). I was struggling to understand how it finds "InferenceEngine_LIBRARIES" (or "OpenCV_LIBS") without even defining it.
I have tried to understand some examples in GitHub but sadly many of them are for older versions. I was wondering if I could have a minimum demo of the CMakeLists.txt to use the OpenVINO. Thank you very much.
--- Updates ---
Thanks for the comments. I understand some things were handled by CMake behind the scene. Going to the point, here is my CMakeLists file
cmake_minimum_required(VERSION 3.21)
project(openvino)
set(CMAKE_CXX_STANDARD 14)
# OpenVINO
set(ngraph_DIR "/opt/intel/openvino_2021/deployment_tools/ngraph/cmake")
find_package(ngraph REQUIRED)
set(InferenceEngine_DIR "/opt/intel/openvino_2021/deployment_tools/inference_engine/share")
find_package(InferenceEngine REQUIRED)
set(OpenCV_DIR "/opt/intel/openvino_2021/opencv/cmake")
find_package(OpenCV REQUIRED)
add_executable(openvino main.cpp)
target_link_libraries(
${PROJECT_NAME}
PRIVATE ${InferenceEngine_LIBRARIES}
${OpenCV_LIBS}
${NGRAPH_LIBRARIES})
And my "main.cpp" is just
#include <inference_engine.hpp>
int main() {
InferenceEngine::Core core;
InferenceEngine::ExecutableNetwork executable_network;
executable_network = core.LoadNetwork("./models/decoder.xml", "CPU");
auto infer_request = executable_network.CreateInferRequest();
return 0;
}
But When I build it, I got the following error, and I would like to ask for any help. Thank you very much!
====================[ Build | openvino | Debug ]================================
/home/kent/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/213.6777.58/bin/cmake/linux/bin/cmake --build /media/kent/DISK2/CLionProjects/openvino/cmake-build-debug --target openvino
[2/2] Linking CXX executable openvino
FAILED: openvino
: && /usr/bin/c++ -g CMakeFiles/openvino.dir/main.cpp.o -o openvino -Wl,-rpath,/opt/intel/openvino_2021/opencv/lib:/opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64:/opt/intel/openvino_2021/deployment_tools/ngraph/lib /opt/intel/openvino_2021/opencv/lib/libopencv_gapi.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_highgui.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_ml.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_objdetect.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_photo.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_stitching.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_video.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_videoio.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_dnn.so.4.5.3 /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine_c_api.so /opt/intel/openvino_2021/deployment_tools/ngraph/lib/libngraph.so /opt/intel/openvino_2021/opencv/lib/libopencv_imgcodecs.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_calib3d.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_features2d.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_flann.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_imgproc.so.4.5.3 /opt/intel/openvino_2021/opencv/lib/libopencv_core.so.4.5.3 && :
/usr/bin/ld: warning: libtbb.so.2, needed by /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_max_concurrency(tbb::interface7::task_arena const*)'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_initialize()'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::concurrent_vector_base_v3::internal_grow_by(unsigned long, unsigned long, void (*)(void*, void const*, unsigned long), void const*)'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::concurrent_vector_base_v3::~concurrent_vector_base_v3()'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::NFS_Allocate(unsigned long, unsigned long, void*)'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::concurrent_vector_base_v3::internal_clear(void (*)(void*, unsigned long))'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_current_slot()'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::allocate_via_handler_v3(unsigned long)'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::NFS_Free(void*)'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::thread_get_id_v3()'
/usr/bin/ld: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine.so: undefined reference to `tbb::internal::deallocate_via_handler_v3(void*)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The linker error shows that it cannot find the TBB symbols. The TBB library should be pointed to by the TBB_DIR variable. You don't have to set those variables manually using cmake's set() function. Instead - in the shell where you compile your own app - you can source OpenVINO's setupvars.sh script. Just run something like: source /opt/intel/openvino_2021/bin/setupvars.sh and re-run the compiler.
I can see you're using CLion, not the terminal directly. In that case you can try adding the variable manually. The TBB location might be slightly different between the OV versions but in general it should point to a subdirectory of /opt/intel/openvino_2021 - just browse the installation directory and try to find it or source setupvars.sh in the terminal and copy the TBB_DIR env var value to your IDE.
I have installed opencv in Ubuntu 20.04 following the instructions in OpenCV Installation in Linux. As per the instructions, sudo make install copies all the .so files to /usr/local/lib.
However, when compiling a program, using the command g++ --std c++17 -g opencv/Basic.cpp -o output -I/usr/local/include/opencv4 -L/usr/local/lib/ -llibopencv_calib3d -llibopencv_core -llibopencv_dnn -llibopencv_features2d -llibopencv_flann -llibopencv_highgui -llibopencv_imgcodecs -llibopencv_imgproc -llibopencv_ml -llibopencv_objdetect -llibopencv_photo -llibopencv_stitching -llibopencv_video -llibopencv_videoio I get the following error.
/usr/bin/ld: cannot find -llibopencv_calib3d
/usr/bin/ld: cannot find -llibopencv_core
/usr/bin/ld: cannot find -llibopencv_dnn
/usr/bin/ld: cannot find -llibopencv_features2d
/usr/bin/ld: cannot find -llibopencv_flann
/usr/bin/ld: cannot find -llibopencv_highgui
/usr/bin/ld: cannot find -llibopencv_imgcodecs
/usr/bin/ld: cannot find -llibopencv_imgproc
/usr/bin/ld: cannot find -llibopencv_ml
/usr/bin/ld: cannot find -llibopencv_objdetect
/usr/bin/ld: cannot find -llibopencv_photo
/usr/bin/ld: cannot find -llibopencv_stitching
/usr/bin/ld: cannot find -llibopencv_video
/usr/bin/ld: cannot find -llibopencv_videoio
collect2: error: ld returned 1 exit status
I have also added a .conf file in /etc/ld.so.conf.d/opencv.conf with the line /usr/local/lib/ and issued the command sudo ldconfig. However, the issue remains.
I'd be grateful for any ideas or suggestions to resolve this issue.
-llibopencv_calib3d
make it
-lopencv_calib3d
etc. the lib part in front of it is simply wrong
I have a large codebase with multiple files and multiple Cmake files as well. The structure is src/folder1 src/folder2 etc and I run catkin_make -j1 from the src directory level. I am unable to link MKL. A small clip of the error is
/usr/bin/ld: /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_intel_thread.so: undefined reference to `mkl_sparse_d_xESB_SpMV_8_i4'
/usr/bin/ld: /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_intel_thread.so: undefined reference to `mkl_spblas_zcoo0ssunc__mmout_par'
/usr/bin/ld: /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_intel_thread.so: undefined reference to `mkl_spblas_zcoo1ntuuf__mmout_par'
/usr/bin/ld: /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_intel_thread.so: undefined reference to `mkl_spblas_lp64_scsr0ntunc__smout_par'
/usr/bin/ld: /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_intel_thread.so: undefined reference to `mkl_spblas_lp64_ccsr0nd_nc__svout_seq'
/usr/bin/ld: /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_intel_thread.so: undefined reference to `mkl_spblas_ccoo1stlnf__svout_seq'
/usr/bin/ld: /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_intel_thread.so: undefined reference to `mkl_pds_pds_her_pos_fwd_ker_seq_nrhs_cmplx'
collect2: error: ld returned 1 exit status
I even added the following line to each cmake:
SET(GCC_COVERAGE_LINK_FLAGS " -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl")
The code does not use MKL BLAS directly but rather it is used by libraries like Opencv and Eigen (OpenCV was built with MKL).
I do define EIGEN_USE_MKL_ALL.
How do I link MKL?
You can make use of oneMKL link line advisor which recommends what are the required libraries and necessary compiler options for the use case on which you are working.
Here is the link
https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl/link-line-advisor.html
I'm failing to build a project in c++ where OpenCV is used. Here is what I got:
/usr/bin/ld: cannot find -leigen
/usr/bin/ld: cannot find -lhighgui
/usr/bin/ld: cannot find -lcore
/usr/bin/ld: cannot find -leigen
/usr/bin/ld: cannot find -lhighgui
/usr/bin/ld: cannot find -lcore
But there are only libraries like "-lopencv_core" available nowadays.
Is there any options how to fix this?
I'm using Ubuntu.
How did you install your distribution of OpenCV. The typical way of installing OpenCV is to download git repo and build it yourself.
I am trying to develop a simple c++ project which uses opencv.I followed http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html website.
But eclipse shows errors like
/usr/bin/ld: cannot find -llibopencv_photo
/usr/bin/ld: cannot find -llibopencv_stitching
/usr/bin/ld: cannot find -llibopencv_superres
/usr/bin/ld: cannot find -llibopencv_ts
/usr/bin/ld: cannot find -llibopencv_video
/usr/bin/ld: cannot find -llibopencv_videostab
/usr/bin/ld: cannot find -llibopencv_calib3d
/usr/bin/ld: cannot find -llibopencv_contrib
/usr/bin/ld: cannot find -llibopencv_ocl
/usr/bin/ld: cannot find -llibopencv_core
/usr/bin/ld: cannot find -llibopencv_core
/usr/bin/ld: cannot find -llibopencv_flann
/usr/bin/ld: cannot find -llibopencv_gpu
/usr/bin/ld: cannot find -llibopencv_highgui
/usr/bin/ld: cannot find -llibopencv_imgproc
/usr/bin/ld: cannot find -llibopencv_legacy
/usr/bin/ld: cannot find -llibopencv_ml
/usr/bin/ld: cannot find -llibopencv_nonfree
/usr/bin/ld: cannot find -llibopencv_objdetect
collect2: ld returned 1 exit status
make: *** [MyProject] Error 1`
I have included libraries and their paths in the following ways.
Project–>Properties
In C/C++ Build ->Settings.
In GCC C++ Compiler ->Includes.
In Include paths(-l) I have added /usr/local/include/opencv.
In GCC C++ Linker
I have added the path (-L) as /usr/local/lib and also library names.
Can anyone please tell me what the reason for this errors?
you have to add the library names without the prefix 'lib'