opencv 4.0 + linux下静态编译,展示详细ccmake的参数配置

#先安装 cmake 3.14

# cmake安装到了 /usr/local/bin

#配置PATH

export PATH="$PATH:/usr/local/bin"

#下载最新的opencv

git clone "https://github.com/opencv/opencv.git"

git clone "https://github.com/opencv/opencv_contrib.git"

#定义自己的生成目录
mkdir 20190508
mkdir -p opencv-master/build
cd opencv-master/build

#生成配置的时候选择带上opencv-contrib

cmake -DOPENCV_EXTRA_MODULES_PATH=/home/admin/opencv/opencv_contrib-master/modules ..

#执行ccmake,配置编译选项

ccmake ..

#我配置的主要选项如下:

 1 BUILD_DOCS:BOOL=OFF
 2 BUILD_EXAMPLES:BOOL=OFF
 3 BUILD_IPP_IW:BOOL=OFF
 4 BUILD_ITT:BOOL=OFF
 5 BUILD_JASPER:BOOL=OFF
 6 BUILD_JAVA:BOOL=OFF
 7 BUILD_JPEG:BOOL=OFF
 8 BUILD_OPENEXR:BOOL=OFF
 9 //Build performance tests
10 BUILD_PERF_TESTS:BOOL=OFF
11 //Build libpng from source
12 BUILD_PNG:BOOL=OFF
13 //Force to build libprotobuf from sources
14 BUILD_PROTOBUF:BOOL=OFF
15 //Build shared libraries (.dll/.so) instead of static ones (.lib/.a)
16 BUILD_SHARED_LIBS:BOOL=OFF
17 //Download and build TBB from source
18 BUILD_TBB:BOOL=OFF
19 //Build accuracy & regression tests
20 BUILD_TESTS:BOOL=OFF
21 //Build libtiff from source
22 BUILD_TIFF:BOOL=OFF
23 //Build WebP from source
24 BUILD_WEBP:BOOL=OFF
25 //Build utility applications (used for example to train classifiers)
26 BUILD_opencv_apps:BOOL=OFF
27 //Include opencv_face module into the OpenCV build
28 BUILD_opencv_face:BOOL=OFF
29 //Include opencv_highgui module into the OpenCV build
30 BUILD_opencv_highgui:BOOL=OFF
31 //Include opencv_java_bindings_generator module into the OpenCV
32 // build
33 BUILD_opencv_java_bindings_generator:BOOL=OFF
34 //Build JavaScript bindings by Emscripten
35 BUILD_opencv_js:BOOL=OFF
36 //Include opencv_xfeatures2d module into the OpenCV build
37 BUILD_opencv_xfeatures2d:BOOL=OFF
38 //Installation Directory
39 CMAKE_INSTALL_PREFIX:PATH=/home/admin/opencv/20190508
40 
41 //Include NVidia Cuda Runtime support
42 WITH_CUDA:BOOL=OFF
43 
44 //Include Intel IPP support
45 WITH_IPP:BOOL=OFF
46 
47 //Include Intel ITT support
48 WITH_ITT:BOOL=OFF
49 
50 //Include JPEG2K support
51 WITH_JASPER:BOOL=OFF
52 
53 //Include JPEG support
54 WITH_JPEG:BOOL=OFF
55 
56 //Include Lapack library support
57 WITH_LAPACK:BOOL=OFF
58 
59 //Include ILM support via OpenEXR
60 WITH_OPENEXR:BOOL=OFF
61 
62 //Include PNG support
63 WITH_PNG:BOOL=OFF
64 
65 //Build with Qt Backend support
66 WITH_QT:BOOL=OFF
67 
68 //Include Intel TBB support
69 WITH_TBB:BOOL=OFF
70 
71 //Include TIFF support
72 WITH_TIFF:BOOL=OFF
73 
74 //Include Vulkan support
75 WITH_VULKAN:BOOL=OFF
76 
77 //Include WebP support
78 WITH_WEBP:BOOL=OFF

配置有这样一些考虑:

1.仅满足linux下的基本的图形处理的使用;
2.不要CUDA,不要各种图形格式的支持;
3.生成静态库,避免多人使用的情况下大家相互覆盖;
4.生成在自己的目录下,不放在系统目录。

 配置完成后按g,生成配置,退出。

make -j 20

make install

 

等到链接具体的程序的时候,还需要额外的一些库:
gcc -o xxx_elf xxx.o -L"/home/admin/opencv/20190508/lib64" -lopencv_core -lopencv_imgproc -lopencv_imgcodecs \

    -ldl -lz -pthread

 

转载于:https://www.cnblogs.com/ahfuzhang/p/10837315.html

你可能感兴趣的:(opencv 4.0 + linux下静态编译,展示详细ccmake的参数配置)