$sudo apt install build-essential unzip pkg-config libjpeg-dev libpng12-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk-3-dev libatlas-base-dev gfortran python3-dev libopenblas-dev
$ git checkout 3.4.2 -b 3.4.2$ mkdir build-3.4.2$ cd build-3.4.2$ cmake -LA ../ (首次运行时间比较长)$ cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \-D CMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -std=c++11" \-D CPACK_GENERATOR=DEB \-D CPACK_BINARY_DEB=ON \-D BUILD_CUDA_STUBS=OFF \-D BUILD_DOCS=OFF \-D BUILD_EXAMPLES=OFF \-D BUILD_IPP_IW=ON \-D BUILD_ITT=ON \-D BUILD_JASPER=OFF \-D BUILD_JPEG=OFF \-D BUILD_OPENEXR=OFF \-D BUILD_PACKAGE=ON \-D BUILD_PERF_TESTS=OFF \-D BUILD_PNG=ON \-D BUILD_PROTOBUF=ON \-D BUILD_SHARED_LIBS=ON \-D BUILD_TBB=OFF \-D BUILD_TESTS=OFF \-D BUILD_TIFF=OFF \-D BUILD_WITH_DEBUG_INFO=ON \-D BUILD_WITH_DYNAMIC_IPP=OFF \-D BUILD_ZLIB=OFF \-D BUILD_opencv_apps=OFF \-D BUILD_opencv_calib3d=OFF \-D BUILD_opencv_core=ON \-D BUILD_opencv_cudaarithm=OFF \-D BUILD_opencv_cudabgsegm=OFF \-D BUILD_opencv_cudacodec=OFF \-D BUILD_opencv_cudafeatures2d=OFF \-D BUILD_opencv_cudafilters=OFF \-D BUILD_opencv_cudaimgproc=OFF \-D BUILD_opencv_cudalegacy=OFF \-D BUILD_opencv_cudaobjdetect=OFF \-D BUILD_opencv_cudaoptflow=OFF \-D BUILD_opencv_cudastereo=OFF \-D BUILD_opencv_cudawarping=OFF \-D BUILD_opencv_cudev=OFF \-D BUILD_opencv_dnn=ON \-D BUILD_opencv_features2d=ON \-D BUILD_opencv_flann=OFF \-D BUILD_opencv_highgui=ON \-D BUILD_opencv_imgcodecs=ON \-D BUILD_opencv_imgproc=ON \-D BUILD_opencv_java=OFF \-D BUILD_opencv_js=OFF \-D BUILD_opencv_ml=OFF \-D BUILD_opencv_objdetect=OFF \-D BUILD_opencv_photo=ON \-D BUILD_opencv_python2=OFF \-D BUILD_opencv_shape=OFF \-D BUILD_opencv_stitching=OFF \-D BUILD_opencv_superres=OFF \-D BUILD_opencv_ts=OFF \-D BUILD_opencv_video=OFF \-D BUILD_opencv_videoio=OFF \-D BUILD_opencv_videostab=OFF \-D BUILD_opencv_world=OFF \-D CMAKE_BUILD_TYPE=Release \-D CMAKE_COLOR_MAKEFILE=OFF \-D CMAKE_CONFIGURATION_TYPES=Release \-D CMAKE_EXPORT_COMPILE_COMMANDS=OFF \-D CMAKE_SKIP_INSTALL_RPATH=NO \-D CMAKE_SKIP_RPATH=NO \-D CPACK_BINARY_IFW=OFF \-D CPACK_BINARY_NSIS=OFF \-D CPACK_BINARY_RPM=OFF \-D CPACK_BINARY_STGZ=OFF \-D CPACK_BINARY_TBZ2=OFF \-D CPACK_BINARY_TGZ=OFF \-D CPACK_BINARY_TXZ=OFF \-D CPACK_BINARY_TZ=OFF \-D CPACK_SOURCE_TBZ2=OFF \-D CPACK_SOURCE_TGZ=OFF \-D CPACK_SOURCE_TXZ=OFF \-D CPACK_SOURCE_TZ=OFF \-D CPACK_SOURCE_ZIP=OFF \-D CPU_BASELINE=SSE3 \-D CPU_DISPATH=SSE4_1 \-D CV_DISABLE_OPTIMIZATION=OFF \-D CV_ENABLE_INTRINSICS=ON \-D CV_TRACE=ON \-D ENABLE_CCACHE=ON \-D ENABLE_COVERAGE=OFF \-D ENABLE_CXX11=ON \-D ENABLE_FAST_MATH=ON \-D ENABLE_GNU_STL_DEBUG=OFF \-D ENABLE_IMPL_COLLECTION=OFF \-D ENABLE_INSTRUMENTATION=OFF \-D ENABLE_NOISY_WARNINGS=OFF \-D ENABLE_OMIT_FRAME_POINTER=ON \-D ENABLE_PRECOMPILED_HEADERS=ON \-D ENABLE_PROFILING=OFF \-D ENABLE_PYLINT=OFF \-D ENABLE_SOLUTION_FOLDERS=OFF \-D INSTALL_CREATE_DISTRIB=OFF \-D INSTALL_C_EXAMPLES=OFF \-D INSTALL_PYTHON_EXAMPLES=OFF \-D INSTALL_TESTS=OFF \-D INSTALL_TO_MANGLED_PATHS=OFF \-D LAPACK_CBLAS_H=cblas.h \-D LAPACK_IMPL:=OpnBLAS \-D LAPACK_INCLUDE_DIR=/usr/include \-D LAPACK_LAPACKE_H=lapacke.h \-D LAPACK_LIBRARIES=/usr/lib/libopenblas.so \-D MKL_WITH_OPENMP=OFF \-D MKL_WITH_TBB=OFF \-D OPENCL_FOUND=ON \-D OPENCV_ENABLE_NONFREE=OFF \-D OPENCV_FORCE_PYTHON_LIBS=OFF \-D OPENCV_WARNINGS_ARE_ERRORS=OFF \-D PROTOBUF_UPDATE_FILES=OFF \-D WITH_1394=OFF \-D WITH_ARAVIS=OFF \-D WITH_CLP=OFF \-D WITH_CUBLAS=OFF \-D WITH_CUDA=OFF \-D WITH_CUFFT=OFF \-D WITH_EIGEN=ON \-D WITH_FFMPEG=ON \-D WITH_GDAL=OFF \-D WITH_GDCM=OFF \-D WITH_GIGEAPI=OFF \-D WITH_GPHOTO2=ON \-D WITH_GSTREAMER=ON \-D WITH_GSTREAMER_0_10=OFF \-D WITH_GTK=ON \-D WITH_GTK_2_X=ON \-D WITH_HALIDE=OFF \-D WITH_IPP=ON \-D WITH_ITT=ON \-D WITH_JASPER=OFF \-D WITH_JPEG=ON \-D WITH_LAPACK=ON \-D WITH_LIBV4L=OFF \-D WITH_MATLAB=ON \-D WITH_MFX=OFF \-D WITH_NVCUVID=ON \-D WITH_OPENCL=OFF \-D WITH_OPENCLAMDBLAS=OFF \-D WITH_OPENCLAMDFFT=OFF \-D WITH_OPENCL_SVM=OFF \-D WITH_OPENEXR=OFF \-D WITH_OPENGL=OFF \-D WITH_OPENMP=OFF \-D WITH_OPENNI=OFF \-D WITH_OPENNI2=OFF \-D WITH_OPENVX=OFF \-D WITH_PNG=ON \-D WITH_PTHREADS_PF=ON \-D WITH_PVAPI=OFF \-D WITH_QT=OFF \-D WITH_TBB=OFF \-D WITH_TIFF=ON \-D WITH_UNICAP=OFF \-D WITH_V4L=OFF \-D WITH_VA=OFF \-D WITH_VA_INTEL=OFF \-D WITH_VTK=OFF \-D WITH_WEBP=OFF \-D WITH_XIMEA=OFF \-D WITH_XINE=OFF \-D opencv_dnn_BUILD_TORCH_IMPORTER=ON \-D opencv_dnn_PERF_CAFFE=OFF \-D opencv_dnn_PERF_CLCAFFE=OFF \-D BUILD_opencv_freetype=ON \-D BUILD_opencv_xfeatures2d=OFF \-D BUILD_opencv_ximgproc=OFF \-D BUILD_opencv_xobjdetect=OFF \-D BUILD_opencv_xphoto=OFF \-D BUILD_opencv_reg=OFF \-D BUILD_opencv_rgbd=OFF \-D BUILD_opencv_saliency=OFF \-D BUILD_opencv_shape=OFF \-D BUILD_opencv_stereo=OFF \-D BUILD_opencv_stitching=OFF \-D BUILD_opencv_structured_light=OFF \-D BUILD_opencv_superres=OFF \-D BUILD_opencv_surface_matching=OFF \-D BUILD_opencv_text=OFF \-D BUILD_opencv_tracking=OFF \-D BUILD_opencv_ts=OFF \-D BUILD_opencv_hdf=OFF \-D BUILD_opencv_plot=OFF \-D BUILD_opencv_line_descriptor=OFF \-D BUILD_opencv_fuzzy=OFF \-D BUILD_opencv_bioinspired=OFF \-D BUILD_opencv_reg=OFF \-D BUILD_opencv_saliency=OFF \-D BUILD_opencv_img_hash=OFF \ ..
默认debian格式打包:make package,如果打成rpm格式,设置CPACK_GENERATOR=RPM和CPACK_BINARY_DEB=OFF