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'
Related
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 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
I'm trying to compile a simple hello world using dmd, but I get the following output:
dmd hi
/usr/bin/ld: hi.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
hi.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
--- errorlevel 1
So I try with -fPIC then
/usr/bin/ld: /usr/lib/libphobos2.a(object_a_66e.o): relocation R_X86_64_32 against `_D12TypeInfo_Aya6__initZ' can not be used when making a shared object; recompile with -fPIC
/usr/lib/libphobos2.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
--- errorlevel 1
This was a non-existent problem a month or so ago.
System: Arch Linux 64bit.
What could possibly be the problem?
dmd -m32 hi
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /lib/../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /lib/../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: cannot find -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.a when searching for -lpthread
collect2: error: ld returned 1 exit status
--- errorlevel 1
The reason why this error was occurring is because of the existence of the hardening-wrapper by https://github.com/thestinger/hardening-wrapper. The removal of this package solved the problem.