Ошибки при связывании OpenCV с программами на C++C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Ошибки при связывании OpenCV с программами на C++

Сообщение Anonymous »

У меня возникли проблемы с компиляцией программ с использованием библиотек opencv 4.13, которые я скомпилировал и установил вручную. В частности, проблема, похоже, в функциях:

Код: Выделить всё

cv::cvtColor
cv::putText
cv::imshow
cv::drawKeypoints
cv::getOptimalNewCameraMatrix
cv::initUndistortRectifyMap
Ниже приведены выходные данные cmake для компиляции OpenCV:

Код: Выделить всё

Detected processor: x86_64
Looking for ccache - found (/usr/bin/ccache)
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
OpenJPEG: VERSION = 2.5.3, BUILD = opencv-4.13.0-openjp2-2.5.3
OpenJPEG libraries will be built from sources: libopenjp2 (version "2.5.3")
found Intel IPP (ICV version): 2022.2.0 [2022.2.0]
at: /home/slam/Documents/opencv_contrib-4.13.0/3rdparty/ippicv/ippicv_lnx/icv
found Intel IPP Integration Wrappers sources: 2022.2.0
at: /home/slam/Documents/opencv_contrib-4.13.0/3rdparty/ippicv/ippicv_lnx/iw
Found OpenBLAS package
OpenBLAS_LIBRARIES=/usr/lib/x86_64-linux-gnu/openblas-pthread//libopenblas.so
OpenBLAS_INCLUDE_DIRS=/usr/include/x86_64-linux-gnu/openblas-pthread/
LAPACK(OpenBLAS): LAPACK_LIBRARIES: /usr/lib/x86_64-linux-gnu/openblas-pthread//libopenblas.so
CMake Warning at cmake/OpenCVFindLAPACK.cmake:60 (message):
LAPACK(OpenBLAS): CBLAS/LAPACK headers are not found in
'/usr/include/x86_64-linux-gnu/openblas-pthread/'
Call Stack (most recent call first):
cmake/OpenCVFindLAPACK.cmake:190 (ocv_lapack_check)
CMakeLists.txt:818 (include)

Could NOT find Atlas (missing: Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY)
LAPACK(LAPACK/Generic): LAPACK_LIBRARIES: /usr/lib/x86_64-linux-gnu/libmkl_intel_lp64.so;/usr/lib/x86_64-linux-gnu/libmkl_intel_thread.so;/usr/lib/x86_64-linux-gnu/libmkl_core.so;/usr/lib/x86_64-linux-gnu/libiomp5.so;-lm;-ldl;-lm;-ldl
LAPACK(LAPACK/Generic): Can't build LAPACK check code. This LAPACK version is not supported.
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Checking for module 'gtkglext-1.0'
Package 'gtkglext-1.0', required by 'virtual:world', not found
Checking for module 'libavdevice'
Package 'libavdevice', required by 'virtual:world', not found
CMake Warning (dev) at modules/videoio/cmake/detect_realsense.cmake:28 (set):
Cannot set "HAVE_LIBREALSENSE": current scope has no parent.
Call Stack (most recent call first):
modules/videoio/cmake/init.cmake:7 (include)
modules/videoio/cmake/init.cmake:21 (add_backend)
cmake/OpenCVModule.cmake:298 (include)
cmake/OpenCVModule.cmake:361 (_add_modules_1)
cmake/OpenCVModule.cmake:408 (ocv_glob_modules)
CMakeLists.txt:1097 (ocv_register_modules)
This warning is for project developers.   Use -Wno-dev to suppress it.

Allocator metrics storage type: 'long long'
Excluding from source files list: /modules/core/test/test_intrin256.lasx.cpp
Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/slam/Documents/opencv-4.13.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out cuda4dnn source code
Excluding from source files list: /modules/dnn/layers/layers_common.rvv.cpp
Excluding from source files list: /modules/dnn/layers/layers_common.lasx.cpp
Excluding from source files list: /modules/dnn/layers/layers_common.neon.cpp
Excluding from source files list: /modules/dnn/layers/layers_common.sve.cpp
Excluding from source files list: /modules/dnn/int8layers/layers_common.rvv.cpp
Excluding from source files list: /modules/dnn/int8layers/layers_common.lasx.cpp
Excluding from source files list: /modules/dnn/int8layers/layers_common.neon.cpp
Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_block.neon.cpp
Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_block.neon_fp16.cpp
Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_depthwise.rvv.cpp
Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_depthwise.lasx.cpp
Excluding from source files list: /modules/dnn/layers/cpu_kernels/fast_gemm_kernels.neon.cpp
Excluding from source files list: /modules/dnn/layers/cpu_kernels/fast_gemm_kernels.lasx.cpp
highgui: using builtin backend: GTK3
Set Cleaners to True
Use autogenerated whitelist /home/slam/Documents/opencv_contrib-4.13.0/modules/js_bindings_generator/whitelist.json
Found 'misc' Python modules from /home/slam/Documents/opencv-4.13.0/modules/python/package/extra_modules
Found 'mat_wrapper;utils' Python modules from /home/slam/Documents/opencv-4.13.0/modules/core/misc/python/package
Found 'gapi' Python modules from /home/slam/Documents/opencv-4.13.0/modules/gapi/misc/python/package
Found 'misc' Python modules from /home/slam/Documents/opencv-4.13.0/modules/python/package/extra_modules
Found 'mat_wrapper;utils' Python modules from /home/slam/Documents/opencv-4.13.0/modules/core/misc/python/package
Found 'gapi' Python modules from /home/slam/Documents/opencv-4.13.0/modules/gapi/misc/python/package

General configuration for OpenCV 4.13.0 =====================================
Version control:               unknown

Platform:
Timestamp:                   2026-01-13T16:47:05Z
Host:                        Linux 6.14.0-37-generic x86_64
CMake:                       3.28.3
CMake generator:             Unix Makefiles
CMake build tool:            /usr/bin/gmake
Configuration:               Release
Algorithm Hint:              ALGO_HINT_ACCURATE

CPU/HW features:
Baseline:                    SSE SSE2 SSE3
requested:                 SSE3
Dispatched code generation:  SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (19 files):         + SSSE3 SSE4_1
SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
AVX (10 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16
AVX2 (39 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16 AVX2 FMA3
AVX512_SKX (10 files):     + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16 AVX2 FMA3 AVX_512F AVX512_COMMON AVX512_SKX

C/C++:
Built as dynamic libs?:      YES
C++ standard:                11
C++ Compiler:                /usr/bin/c++  (ver 13.3.0)
C++ flags (Release):         --std=c++17   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
C++ flags (Debug):            --std=c++17   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
C Compiler:                  /usr/bin/cc
C flags (Release):           -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse3 -fvisibility=hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
C flags (Debug):             -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse3 -fvisibility=hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
ccache:                      YES
Precompiled headers:         NO
Extra dependencies:          dl m pthread rt
3rdparty dependencies:

OpenCV modules:
To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java ml objdetect photo python3 stitching ts video videoio
Disabled:                    world
Disabled by dependency:      -
Unavailable:                 python2
Applications:                tests perf_tests apps
Documentation:               NO
Non-free algorithms:         YES

GUI:                           GTK3
GTK+:                        YES (ver 3.24.41)
OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
VTK support:                 NO

Media I/O:
ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.3)
JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver decoder: 0x0209, encoder: 0x020f, demux: 0x0107)
AVIF:                        avif (ver 1.0.4)
PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.43)
TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.5.1)
JPEG 2000:                   build (ver 2.5.3)
OpenEXR:                     OpenEXR::OpenEXR (ver 3.1.5)
GIF:                         YES
HDR:                         YES
SUNRASTER:                   YES
PXM:                         YES
PFM:                         YES

Video I/O:
FFMPEG:                      YES
avcodec:                   YES (60.31.102)
avformat:                  YES (60.16.100)
avutil:                    YES (58.29.100)
swscale:                   YES (7.5.100)
avdevice:                  NO
GStreamer:                   YES (1.24.2)
v4l/v4l2:                    YES (linux/videodev2.h)
Intel RealSense:             YES (2.57.5)
Orbbec:                      YES

Parallel framework:            OpenMP

Trace:                         YES (with Intel ITT(3.25.4))

Other third-party libraries:
Intel IPP:                   2022.2.0 [2022.2.0]
at:                   /home/slam/Documents/opencv_contrib-4.13.0/3rdparty/ippicv/ippicv_lnx/icv
Intel IPP IW:                sources (2022.2.0)
at:                /home/slam/Documents/opencv_contrib-4.13.0/3rdparty/ippicv/ippicv_lnx/iw
VA:                          YES
Lapack:                      NO
Eigen:                       YES (ver 5.0.0)
Custom HAL:                  YES (ipp (ver 0.0.1))
Protobuf:                    build (3.19.1)
Flatbuffers:                 builtin/3rdparty (25.9.23)

Vulkan:                         YES
Include path:                /home/slam/Documents/opencv-4.13.0/3rdparty/include
Link libraries:              Dynamic load

OpenCL:                        YES (INTELVA)
Include path:                /home/slam/Documents/opencv-4.13.0/3rdparty/include/opencl/1.2
Link libraries:              Dynamic load

Python 3:
Interpreter:                 /usr/bin/python3 (ver 3.12.3)
Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.12.so (ver 3.12.3)
Limited API:                 NO
numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.26.4)
install path:                lib/python3.12/dist-packages/cv2/python-3.12

Python (for build):            /usr/bin/python3

Java:
ant:                         NO
Java:                        YES (ver 21.0.9)
JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
Java wrappers:               YES (JAVA)
Java tests:                  NO

Install to:                    /usr/local
-----------------------------------------------------------------

Configuring done (1.8s)
Generating done (0.2s)
Несколько вещей, которые я уже пробовал:
  • Я распечатал версию OpenCV, когда программа компиляции C++ завершилась успешно, это была версия 4.13.
  • Я удалил все остальные библиотеки opencv из системы.
  • Я передаю g++ правильные адреса для ссылки: -L/usr/local/lib/ -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lboost_program_options (я проверил, все библиотеки были там)
Если кто-нибудь может хотя бы помочь с предложением о том, что может быть не так, я буду очень благодарен.
On личное замечание: я не впервые компилирую OpenCV. На самом деле наоборот, я начал его компилировать начиная с 2.4 и действительно похоже, что стало практически невозможно корректно отключить функции, которые вам не нужны/не нужны, и при этом ничего не сломать. Я использую ноутбук с 5080, и мне было сложно компилировать всю эту чушь CUDA.

Подробнее здесь: https://stackoverflow.com/questions/798 ... c-programs
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»