I need to build OpenCV from source and I have limited space, so, I have to build OpenCV on a module basis (https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html - Build limited set of modules). OK, cmake and make work fine.
Would be easier to use these OpenCV modules from python so I add cmake -D BUILD_opencv_python3=ON but make install does not create the prefix/lib/pythonX.Y/site-packages directory I expected. There is no python related option but only a CMake option as far as I understand the doc.
How to get python(3) binding for OpenCV when building it on a module basis ?
Once installed, how to set up environnement to get python -c "import cv2" to work with my custom-built OpenCV ?
UPDATE
Running ubuntu L4T on jetson. CMake outputs :
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.6.9)
-- Libraries: NO
-- numpy: /home/me/.local/lib/python3.6/site-packages/numpy/core/include (ver 1.19.5)
-- install path: -
So I guess empty install path hides a problem behind... But grep -ni OPENCV_PYTHON3_INSTALL_PATH CMakeCache.txt returns nothing.
At this point, I tried to add cmake -DOPENCV_PYTHON3_INSTALL_PATH=~/Programs/opencv/local/lib/python3.6/site-packages/, still nothing in cmake output (blank install path) but
grep -ni OPENCV_PYTHON3_INSTALL_PATH CMakeCache.txt
1076:OPENCV_PYTHON3_INSTALL_PATH:UNINITIALIZED=~/Programs/opencv/local/lib/python3.6/site-packages/
And after make install (without sudo - I don't have root privilege and need local install), I have no python binding in the local install.
... Any clue would be appreciated !
Note: compiling opencv-4.5.4 on L4T ubuntu
I wanted to add to CYL answer, I use that GitHub Gist and it works, but I have to drop all my junk cmake flags.
Here is what I ultimately end up with.
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=ON \
-D WITH_TBB=ON \
-D WITH_CUDA=OFF \
-D BUILD_opencv_cudacodec=OFF \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_V4L=ON \
-D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D WITH_GSTREAMER=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv.pc \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_PYTHON3_INSTALL_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D OPENCV_EXTRA_MODULES_PATH=/tmp/opencv_contrib/modules \
-D PYTHON_EXECUTABLE=$(which python3) \
-D BUILD_EXAMPLES=ON ..
and this is the General Config output
-- General configuration for OpenCV 4.5.5 =====================================
-- Version control: 4.5.5
--
-- Extra modules:
-- Location (extra): /tmp/opencv_contrib/modules
-- Version control (extra): 4.5.5
--
-- Platform:
-- Timestamp: 2022-01-23T08:47:55Z
-- Host: Linux 5.11.0-41-generic x86_64
-- CMake: 3.18.2
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: RELEASE
--
-- CPU/HW features:
-- Baseline: SSE SSE2 SSE3
-- requested: SSE3
-- Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
-- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
-- SSE4_1 (18 files): + SSSE3 SSE4_1
-- SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
-- FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
-- AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
-- AVX2 (33 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ standard: 11
-- C++ Compiler: /usr/bin/c++ (ver 9.3.0)
-- C++ flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-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 -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-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 -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/cc
-- C flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-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 -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-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 -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed
-- Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: dl m pthread rt
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: alphamat cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java julia matlab ovis python2 sfm viz
-- Applications: tests perf_tests examples apps
-- Documentation: NO
-- Non-free algorithms: YES
--
-- GUI: NONE
-- GTK+: NO
-- OpenGL support: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
-- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
-- JPEG 2000: build (ver 2.4.0)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: NO
-- FFMPEG: YES
-- avcodec: YES (58.54.100)
-- avformat: YES (58.29.100)
-- avutil: YES (56.31.100)
-- swscale: YES (5.5.100)
-- avresample: YES (4.0.0)
-- GStreamer: YES (1.16.2)
-- v4l/v4l2: YES (linux/videodev2.h)
--
-- Parallel framework: TBB (ver 2020.1 interface 11101)
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Intel IPP: 2020.0.0 Gold [2020.0.0]
-- at: /tmp/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
-- Intel IPP IW: sources (2020.0.0)
-- at: /tmp/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
-- VA: NO
-- Lapack: NO
-- Eigen: NO
-- Custom HAL: NO
-- Protobuf: build (3.19.1)
--
-- OpenCL: YES (no extra features)
-- Include path: /tmp/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /home/user/miniconda3/bin/python3 (ver 3.9.5)
-- Libraries: /home/user/miniconda3/lib/libpython3.9.so (ver 3.9.5)
-- numpy: /home/user/miniconda3/lib/python3.9/site-packages/numpy/core/include (ver 1.21.2)
-- install path: /home/user/miniconda3/lib/python3.9/site-packages/cv2/python-3.9
--
-- Python (for build): /home/user/miniconda3/bin/python3
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /home/user/miniconda3
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/opencv/build
Just for documentation, this is what I install on the ubuntu 20.04.
apt-get update && apt-get install git openssh-client curl wget sudo \
build-essential pkg-config libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-test-dev \
libgl1-mesa-glx libglib2.0-0 \
libjpeg-dev libpng-dev libtiff-dev \
libavcodec-dev libavformat-dev libswscale-dev libavresample-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libxvidcore-dev x264 libx264-dev libfaac-dev libmp3lame-dev libtheora-dev \
libfaac-dev libmp3lame-dev libvorbis-dev \
libtbb-dev libatlas-base-dev gfortran -y
To have py binding, make sure the cmake config output near the end has the Python 3 section i.e.
Python 3:
Interpreter: /home/user/anaconda3/envs/cv451/bin/python3 (ver 3.8.12)
Libraries: /home/user/anaconda3/envs/cv451/lib/libpython3.8.so (ver 3.8.12)
numpy: /home/user/anaconda3/envs/cv451/lib/python3.8/site-packages/numpy/core/include (ver 1.21.2)
install path: /home/user/anaconda3/envs/cv451/lib/python3.8/site-packages/cv2/python-3.8
For me that section was missing at first. My problem was python version mismatch between the lib (found from system) and the interpreter (from conda env).
Thus in my case the fix was:
Have cmake find the conda env's python instead of the system's python:
CMAKE_LIBRARY_PATH=/home/user/anaconda3/envs/cv451/lib cmake /path/to/opencv/arc
By default the binding is installed to system's python. To specify the python binding install path, use the cmake flag OPENCV_PYTHON3_INSTALL_PATH i.e.
-D OPENCV_PYTHON3_INSTALL_PATH=/home/user/anaconda3/envs/cv451/lib/python3.8/site-packages/
Remember to install after the compile
sudo make install
Ref:
https://gist.github.com/raulqf/f42c718a658cddc16f9df07ecc627be7
https://qengineering.eu/install-opencv-4.5-on-jetson-nano.html
cmake -DBUILD_LIST=python3 .. solved the problem: getting clean install directory including python site-packages directory.
Related
I'm coding a C++ library on Linux, the lib name is libic. libic use openssl. When I build libic on host Ubuntu 18.04, no error occurs. But when I cross-compile libic for arm, linker error when building libic shared target. The error is like below:
....
[100%] Linking CXX shared library libic.so
uclient.c:(.text+0xd96): undefined reference to `event_del'
uclient.c:(.text+0xd9e): undefined reference to `event_free'
uclient.c:(.text+0xdae): undefined reference to `event_del'
uclient.c:(.text+0xdb6): undefined reference to `event_free'
uclient.c:(.text+0xdf8): undefined reference to `SSL_get_shutdown'
uclient.c:(.text+0xe0a): undefined reference to `SSL_free'
uclient.c:(.text+0xe5c): undefined reference to `SSL_free'
uclient.c:(.text+0xe90): undefined reference to `event_base_free'
uclient.c:(.text+0xe98): undefined reference to `pthread_cancel'
uclient.c:(.text+0xed6): undefined reference to `SSL_get_shutdown'
uclient.c:(.text+0xefa): undefined reference to `SSL_set_shutdown'
uclient.c:(.text+0xf06): undefined reference to `SSL_shutdown'
uclient.c:(.text+0xf12): undefined reference to `SSL_set_shutdown'
uclient.c:(.text+0xf1a): undefined reference to `SSL_shutdown'
The configure log is below
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found OpenSSL: /home/drone/tizen-studio/platforms/tizen-3.0/mobile/rootstraps/mobile-3.0-device.core/usr/lib/libcrypto.so (found version "1.0.2k")
-- Using OpenSSL 1.0.2k
-- Found CURL: /home/drone/tizen-studio/platforms/tizen-3.0/mobile/rootstraps/mobile-3.0-device.core/usr/lib/libcurl.so (found version "7.50.2")
--
-- C/C++:
-- C++ Compiler: /home/drone/Downloads/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ (ver 7.3.1)
-- C++ flags (Release): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -std=c++1y -fPIC -O3 -DNDEBUG
-- C++ flags (Debug): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -std=c++1y -fPIC -g
-- C Compiler: /home/drone/Downloads/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc
-- C flags (Release): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -O3 -DNDEBUG
-- C flags (Debug): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -g
-- CMAKE_INSTALL_PREFIX: /home/drake/Documents/code/libscs/packages/libscs
-- Linker flags (Release): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
-- Linker flags (Debug): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
It seems with cross compile, libic requires to link with openssl. I want to ask that how can I build libic shared without linking with openssl?
Thanks for your support.
If your library depends on libssl, you cannot compile it without linking to libssl. Did you try getting the libssl package for the arm architecture? Off the top of my head, something around the lines of
dpkg --add-architecture arm
apt update
apt install libssl-dev:arm
Or maybe
dpkg --add-architecture arm64
apt update
apt install libssl-dev:arm64
Hope this helps!
Thank you guys, I've found the answer, the linker issue occurs because of this linker flag -Wl,--no-undefined. Just remove this linker option is OK
I am using python 3.6 and opencv 3.4.1 to capture video from a Logitech C920 webcam. I am used to Windows, where I would write my own DirectShow filters to get access to frames and control the camera. I am finding myself out of my depth on Linux.
I know it can run 24fps at least by using GTK UVC video viewer, but I'm only getting 5fps. I suspect that this is due to the format - to get higher rates I need something like x264. It may be that this is impossible for opencv because it means that it can no longer grab a single frame.
I have tried setting the video codec, but I am told that
cap.set(cv2.CAP_PROP_FORMAT, cv2.VideoWriter_fourcc(...
VIDEOIO ERROR: V4L2: setting property #8 is not supported
Other people have asked similar questions, but I haven't been able to see a convincing answer:
(no answer)
Capturing H264 stream with OpenCV
(blames drivers)
http://answers.opencv.org/question/30185/frame-capture-is-needlessly-slow/
(sets camera format in c++)
OpenCV VideoCapture with H264 CODEC
(also done in c++ and OpenCV 2.4)
Capturing 1080p at 30fps from logitech c920 with openCV 2.4.3
I found a link claiming that x264 etc doesn't support frame grabbing, therefore it can't be done, but now I can't find it - this would seem to be contradicted by the answers in c++ and the fact that we can work with x264 file formats.
Any clarity would be appreciated.
EDIT:
As requested, here are the outputs of cv2.getBuildInformation():
General configuration for OpenCV 3.4.1 =====================================
Version control: 3.4.1
Platform:
Timestamp: 2018-05-19T13:51:11Z
Host: Linux 4.4.0-101-generic x86_64
CMake: 3.9.0
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/gmake
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (3 files): + SSSE3 SSE4_1
SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (9 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
C/C++:
Built as dynamic libs?: NO
C++ Compiler: /opt/rh/devtoolset-2/root/usr/bin/c++ (ver 4.8.2)
C++ flags (Release): -Wl,-strip-all -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -Wl,-strip-all -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /opt/rh/devtoolset-2/root/usr/bin/cc
C flags (Release): -Wl,-strip-all -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -Wl,-strip-all -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -L/root/ffmpeg_build/lib
Linker flags (Debug): -L/root/ffmpeg_build/lib
ccache: NO
Precompiled headers: NO
Extra dependencies: /opt/Qt4.8.7/lib/libQtGui.so /opt/Qt4.8.7/lib/libQtTest.so /opt/Qt4.8.7/lib/libQtCore.so /lib64/libz.so /opt/libjpeg-turbo/lib64/libjpeg.a avcodec avformat avutil swscale dl m pthread rt
3rdparty dependencies: ittnotify libprotobuf libwebp libpng libtiff libjasper IlmImf
OpenCV modules:
To be built: calib3d core dnn features2d flann highgui imgcodecs imgproc java_bindings_generator ml objdetect photo python3 python_bindings_generator shape stitching superres video videoio videostab
Disabled: js world
Disabled by dependency: -
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2ts viz
Applications: -
Documentation: NO
Non-free algorithms: NO
GUI:
QT: YES (ver 4.8.7 EDITION = OpenSource)
QT OpenGL support: NO
GTK+: NO
VTK support: NO
Media I/O:
ZLib: /lib64/libz.so (ver 1.2.3)
JPEG: /opt/libjpeg-turbo/lib64/libjpeg.a (ver )
WEBP: build (ver encoder: 0x020e)
PNG: build (ver 1.6.34)
TIFF: build (ver 42 - 4.0.9)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
Video I/O:
DC1394: NO
FFMPEG: YES
avcodec: YES (ver 58.19.100)
avformat: YES (ver 58.13.100)
avutil: YES (ver 56.18.100)
swscale: YES (ver 5.2.100)
avresample: NO
GStreamer: NO
libv4l/libv4l2: NO
v4l/v4l2: linux/videodev.h linux/videodev2.h
gPhoto2: NO
Parallel framework: pthreads
Trace: YES (with Intel ITT)
Other third-party libraries:
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
NVIDIA CUDA: NO
OpenCL: YES (no extra features)
Include path: /io/opencv/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 3:
Interpreter: /opt/python/cp36-cp36m/bin/python (ver 3.6.5)
Libraries: libpython3.6m.a (ver 3.6.5)
numpy: /opt/python/cp36-cp36m/lib/python3.6/site-packages/numpy/core/include (ver 1.11.3)
packages path: lib/python3.6/site-packages
Python (for build): /opt/python/cp36-cp36m/bin/python
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab: NO
Install to: /io/_skbuild/cmake-install
-----------------------------------------------------------------
So as zindarod correctly pointed out, the solution is to:
run cv2.getBuildInformation()
Check if libv4l/libv4l2 has NO/NO as the value (if it doesn't you have some other problem)
Compile OpenCV from source.
Compiling OpenCV is tricky, but manageable, even for someone like me who was raised on Windows.
https://docs.opencv.org/3.2.0/d7/d9f/tutorial_linux_install.html
https://docs.opencv.org/3.0-beta/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html
Although those are a little out of date. In eclipse you'll need references to
opencv_videoio
opencv_core
opencv_highgui
opencv_videoio
#include "opencv2/opencv.hpp"
#include "opencv2/videoio.hpp"
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
cap.set(CV_CAP_PROP_FRAME_WIDTH,1920);
cap.set(CV_CAP_PROP_FRAME_HEIGHT,1080);
Mat edges;
namedWindow("camera",1);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
imshow("camera", frame);
if(waitKey(30) >= 0) break;
}
return 0;
}
why am I getting "fatal error: asm/early_ioremap.h: No such file or directory" while building simple hello world kernel driver for x86_64 with Linux 4.4.15 libraries using gcc-4.8.5? gcc is searching for asm/early_ioremap.h which is not available in Linux 4.4.15.
any idea how can i fix this?
/opt/gcc-4.8.5-glibc-2.21-p8/x86_64-linux-gnu/bin/x86_64-linux-gnu-gcc -M -MP -MT '/home/obj/src/kernel/hello_world/hello.o' -MT '/home/obj/src/kernel/hello_world/hello.d' -MT 'hello.E' -MT 'hello.S' -I/home/src/kernel/hello_world -I/home/obj/src/kernel/linux-4.4.15/include -I/home/src/inc -I/home/obj/src/kernel/linux-4.4.15/arch/x86/include -D__KERNEL__ -DMODULE -DPACKET_LEAK_TRACING -DSIZEOF_CPU_REGISTER=8 -DNUM_DEV_CF=0 -DNUM_DEV_USB=0 -mtune=nocona -march=nocona -m64 -pipe -std=gnu89 -g -nostdinc -isystem /opt/gcc-4.8.5-glibc-2.21-p8/x86_64-linux-gnu/lib/gcc/x86_64-linux-gnu/4.8.5/include -O2 -fno-strict-aliasing -fno-common -ffreestanding -Wall -Wstrict-prototypes -Wno-trigraphs -Wmissing-format-attribute -Wdisabled-optimization -Wwrite-strings -Wimplicit-int -Wmissing-braces -Wmissing-noreturn -Wundef -Wmissing-field-initializers -Wmissing-declarations -Wmissing-prototypes -Wno-unused-parameter -Winline -mcmodel=kernel -fno-omit-frame-pointer -fno-stack-protector -mno-red-zone -fno-asynchronous-unwind-tables -imacros generated/autoconf.h hello.c -I/home/obj/src/kernel/linux-4.4.15/include/uapi/ -I/home/obj/src/kernel/linux-4.4.15/arch/x86/include/uapi/
In file included from /home/obj/src/kernel/linux-4.4.15/arch/x86/include/asm/realmode.h:5:0,
from /home/obj/src/kernel/linux-4.4.15/arch/x86/include/asm/acpi.h:33,
from /home/obj/src/kernel/linux-4.4.15/arch/x86/include/asm/fixmap.h:19,
from /home/obj/src/kernel/linux-4.4.15/arch/x86/include/asm/apic.h:12,
from /home/obj/src/kernel/linux-4.4.15/arch/x86/include/asm/smp.h:12,
from /home/obj/src/kernel/linux-4.4.15/arch/x86/include/asm/mmzone_64.h:10,
from /home/obj/src/kernel/linux-4.4.15/arch/x86/include/asm/mmzone.h:4,
from /home/obj/src/kernel/linux-4.4.15/include/linux/mmzone.h:856,
from /home/obj/src/kernel/linux-4.4.15/include/linux/gfp.h:5,
from /home/obj/src/kernel/linux-4.4.15/include/linux/kmod.h:22,
from /home/obj/src/kernel/linux-4.4.15/include/linux/module.h:13,
from hello.c:1:
/home/obj/src/kernel/linux-4.4.15/arch/x86/include/asm/io.h:43:31: fatal error: asm/early_ioremap.h: No such file or directory
#include <asm/early_ioremap.h>
^
compilation terminated.
gcc is searching for asm/early_ioremap.h which is not available in Linux 4.4.15.
any idea how can i fix this?
I think you've answered your own question; either you figure out where the functionality contained in that header file has moved, or with what it has been replaced, or you use a Linux 4.4.15-compatible hello world module, or you use an older kernel.
Personally, I'd go for trying out another example that is supposed to work with recent versions of Linux.
I've faced a very similar error just recently trying to build a module from the kernel to an out-of-tree output by specifying the O= flag.
It seems to be that this is the part causing the failure for me
make \
-j1 \
-C /lib/modules/4.17.9-041709-generic/build \
M=/home/kbingham/sources/linux/drivers/media/usb/uvc \
O=/tmp/build-uvc \
V=1 \
modules
fails,
with the error:
/usr/src/linux-headers-4.17.9-041709-generic/arch/x86/include/asm/io.h:44:10: fatal error: asm/early_ioremap.h: No such file or directory
#include <asm/early_ioremap.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
whilst
make \
-j1 \
-C /lib/modules/4.17.9-041709-generic/build \
M=/home/kbingham/sources/linux/drivers/media/usb/uvc \
V=1 \
modules
suceeds.
I'm trying to compile a library on Ubuntu 14.04 with packages gcc-arm-linux-gnueabi and g++-arm-linux-gnueabi installed.
The compile fails on the first source file it encounters:
/usr/bin/arm-linux-gnueabi-g++ -DNDEBUG -g2 -Os -pipe -fPIC -I. -DCRYPTOPP_DISABLE_ASM
-mcpu=cortex-m3 -mthumb --sysroot=/usr/arm-linux-gnueabi -c 3way.cpp
In file included from cryptlib.h:83:0,
from seckey.h:8,
from 3way.h:7,
from 3way.cpp:5:
stdcpp.h:14:18: fatal error: memory: No such file or directory
compilation terminated.
Here's what the include line looks like in cryptlib.h:
#ifndef CRYPTOPP_CRYPTLIB_H
#define CRYPTOPP_CRYPTLIB_H
#include "config.h"
#include "stdcpp.h"
...
Obviously, stdcpp.h exists:
$ pwd
/home/jwalton/cryptopp-embedded
$ ls 3way.h cryptlib.h stdcpp.h
3way.h cryptlib.h stdcpp.h
Adding -v shows:
...
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/include"
#include "..." search starts here:
#include <...> search starts here:
.
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/include
...
End of search list.
I've cross compiled the library on other platforms (like Android, iOS and Windows Phone), so I have a good idea of what needs to be done. This is my first time with arm-linux-gnueabi, however.
Why is arm-linux-gnueabi skipping the header in the present working directory? How can I resolve the issue?
Full output from arm-linux-gnueabi-g++ -v:
/usr/bin/arm-linux-gnueabi-g++ -v -DNDEBUG -g2 -Os -pipe -fPIC -I. -DCRYPTOPP_DISABLE_ASM
-mcpu=cortex-m3 -mthumb --sysroot=/usr/arm-linux-gnueabi -c 3way.cpp
Using built-in specs.
COLLECT_GCC=/usr/bin/arm-linux-gnueabi-g++
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++
--prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabi/include/c++/4.7.3
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-gnu-unique-object
--disable-libmudflap --disable-libitm --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog
--enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --enable-multilib
--disable-sjlj-exceptions --with-arch=armv5t --with-float=soft --disable-werror --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueab --program-prefix=arm-linux-gnueabi-
--includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1)
COLLECT_GCC_OPTIONS='-v' '-D' 'NDEBUG' '-g2' '-Os' '-pipe' '-fPIC' '-I' '.' '-D' 'CRYPTOPP_DISABLE_ASM'
'-mcpu=cortex-m3' '-mthumb' '-c' '-shared-libgcc' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/cc1plus -quiet -v -I . -imultilib sf -imultiarch
arm-linux-gnueabi
-isysroot /usr/arm-linux-gnueabi -D_GNU_SOURCE -D NDEBUG -D CRYPTOPP_DISABLE_ASM
3way.cpp -quiet
-dumpbase 3way.cpp -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -mtls-dialect=gnu -auxbase 3way
-g2 -Os -version -fPIC -fstack-protector -o - |
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/as -v -I . -mcpu=cortex-m3
-mfloat-abi=soft -meabi=5 -o 3way.o
GNU assembler version 2.24 (arm-linux-gnueabi) using BFD version (GNU Binutils for Ubuntu) 2.24
GNU C++ (Ubuntu/Linaro 4.7.3-12ubuntu1) version 4.7.3 (arm-linux-gnueabi)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/arm-linux-gnueabi/include/c++/4.7.3"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/arm-linux-gnueabi/include/c++/4.7.3/arm-linux-gnueabi/sf"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/arm-linux-gnueabi/include/c++/4.7.3/backward"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/local/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/include"
#include "..." search starts here:
#include <...> search starts here:
.
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/include
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/include-fixed
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/include
End of search list.
GNU C++ (Ubuntu/Linaro 4.7.3-12ubuntu1) version 4.7.3 (arm-linux-gnueabi)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: dd2bb0d8e9ec09589fb3eaca028d0191
In file included from cryptlib.h:83:0,
from seckey.h:8,
from 3way.h:7,
from 3way.cpp:5:
stdcpp.h:14:18: fatal error: memory: No such file or directory
compilation terminated.
make: *** [3way.o] Error 1
stdcpp.h:14:18: fatal error: memory: No such file or directory
Arg... The missing header is memory, and not stdcpp.h. (Damn C++ header names...).
And the un-found <memory> appears to be a bug in Ubuntu's g++arm-linux-gnueabi: g++-arm-linux-gnueabi cannot compile a C++ program with --sysroot.
The following error came up when i did 'make' of glibc-2.14.1 for LFS 7.1. I am using ubuntu as the host OS.
gcc ../sysdeps/unix/sysv/linux/syslog.c -c -std=gnu99 -fgnu89-inline -O2 -Wall -Winline
-Wwrite-strings -fmerge-all-constants -g -Wstrict-prototypes -mpreferred-stack-
boundary=2 -Wa,-mtune=i686 -fexceptions -I../include -I/mnt/lfs/sources/glibc-
build/misc -I/mnt/lfs/sources/glibc-build -I../sysdeps/i386/elf -
I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/unix/sysv/linux/i386/i686 -
I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -
I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -
I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -
I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv/i386 -
I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -
I../nptl/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -
I../sysdeps/i386/i686/multiarch -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -
I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -
I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -
I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -
I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl -I.. -
I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-linux-gnu/4.6/include -isystem
/usr/lib/gcc/i686-linux-gnu/4.6/include-fixed -isystem /tools/include -D_LIBC_REENTRANT
-include ../include/libc-symbols.h -o /mnt/lfs/sources/glibc-build/misc/syslog.o
-MD -MP -MF /mnt/lfs/sources/glibc-build/misc/syslog.o.dt -MT /mnt/lfs/sources/glibc-
build/misc/syslog.o
In file included from ../sysdeps/unix/sysv/linux/syslog.c:10:0:
../misc/syslog.c: In function '__vsyslog_chk':
../misc/syslog.c:144:9: warning: variable 'prioff' set but not used [-Wunused-but-set-
variable]
../misc/syslog.c:123:1: sorry, unimplemented: inlining failed in call to 'syslog':
function body not available
../misc/syslog.c:155:9: sorry, unimplemented: called from here
make[2]: *** [/mnt/lfs/sources/glibc-build/misc/syslog.o] Error 1
make[2]: Leaving directory `/mnt/lfs/sources/glibc-2.14.1/misc'
make[1]: *** [misc/subdir_lib] Error 2
make[1]: Leaving directory `/mnt/lfs/sources/glibc-2.14.1'
make: *** [all] Error 2
Can anyone tell me what to do?
For glibc 2.15, I had to do like ks1322:
$ ../glibc2.15/configure CFLAGS="-O2 -U_FORTIFY_SOURCE -fno-stack-protector"
$ make
The -O2 is required to recover the default optimisation, required to avoid a number of failures.
The -U_FORTIFY_SOURCE is required to avoid failure of gcc ../sysdeps/unix/sysv/linux/syslog.c (In function ‘__vsyslog_chk’: [...] inlining failed in call to ‘syslog’)
The -fno-stack-protector is required to avoid failure of gcc [...] elf/dl-allobjs.os libc_pic.a ((init-first.os):(.data+0x0): multiple definition of '__libc_multiple_libcs').
With these CFLAGS, I get just a warning (errlist.c count 133 inflated to GLIBC_2.12 count 134 (old errno.h?)).
P.S. It is also very important to not use the gold linker (ld.gold, from the binutils-gold package), because libc's config will reject it. This is easily done by changing the /usr/bin/ld symbolic link from ld.gold to ld.bfd.
After make failed, the following worked for me:
make clean
make -j2 CFLAGS="-U_FORTIFY_SOURCE -O2 -fno-stack-protector"
See details in this blog http://www.yonch.com/tech/78-compiling-glibc.
glibc build issues, inlining failed
Need to add -U_FORTIFY_SOURCE to the gcc invocation.
#avinash - try the following ...
1) re-run configure ... CFLAGS="-O2 -U_FORTIFY_SOURCE" ./configure
2) re-run make ... CFLAGS="-O2 -U_FORTIFY_SOURCE" make