将OpenCV构建为静态库 [英] Building OpenCV as static libraries

查看:190
本文介绍了将OpenCV构建为静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我缺少一些东西,但是我无法构建opencv的静态库。



安装:



Kubuntu 12.04



gcc 4.6.3



make 3.81



cmake 2.8.7



opencv 2.4.6.1(最后一个可用的网站)



我手动做所有的工作。我尝试使用cmake-gui没有更多的成功。



我做它是写的。



$ cmake -D CMAKE_BUILD_TYPE = RELEASE -D CMAKE_INSTALL_PREFIX = / usr / local -D BUILD_PYTHON_SUPPORT = ON -D WITH_QT = ON -D BUILD_SHARED_LIBRARIES = OFF ..



BUILD_SHARED_LIBRARIES = NO)



我得到的是(例如核心):




  • libopencv_core.so

  • libopencv_core.so.2.4

  • libopencv_core.so.2.4.6

  • libopencv_core_pch_dephelp.a



说实话,我期望 libopencv_core.a



我是Linux上的package / libs的新手。我肯定有一些我做错了,但我不知道什么。此外,我不想使用动态库...



感谢您的帮助!



EDIT 删除cmake命令行中的-D ...之间的空格

 结果:

- OpenCV的一般配置2.4.6.1 =====================================
- 版本控制:未知
-
- 平台:
- 主机:Linux 3.2.0-51-generic x86_64
- CMake:2.8 .7
- CMake生成器:Unix Makefiles
- CMake构建工具:/ usr / bin / make
- 配置:RELEASE
-
- C / C ++:
- 构建为动态库?:YES
- C ++编译器:/ usr / bin / c ++(ver 4.6)
- C ++ flags -char -W -Wall -Werror = return-type -Werror = address -Werror = sequence-point -Wformat -Werror = format-security -Wmissing- declarations-Wundef-Winit- self-Wpointer- arith-Wshadow-Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG-DNDEBUG
- C ++标志(调试):-fsigned-char -W -Wall -Werror =返回类型-Werror =地址-Werror =序列点-Wformat -Werror = format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics -show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3
- C编译器:/ usr / bin / gcc
- C flags(Release):-fsigned-char -W -Wall -Werror = return-type -Werror = address -Werror = sequence-point -Wformat -Werror = format-security -Wmissing-声明-Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-选项-Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG -DNDEBUG
- C标志(调试):-fsigned-char -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 - Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 - ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3
- 链接器标志(发布):
- 链接器标志(调试):
- 预编译头:YES
-
- OpenCV模块:
- 待构建:core imgproc flann highgui features2d calib3d ml video objdetect contrib photo legacy gpu nonfree java python stitching superres ts videostab

...

 配置done 
- 生成完成
CMake警告:
项目未使用手动指定的变量:

BUILD_PYTHON_SUPPORT
BUILD_SHARED_LIBRARIES
$ <$> $ <$>

我仍然看到构建为动态库:,它告诉我,

解决方案

查看 github.com/Itseez/opencv/blob/master/CMakeLists.txt> OpenCV的CMakeLists.txt ,它看起来好像你使用错误的名称为OpenCV CMake选项。



BUILD_SHARED_LIBRARIES 应为 BUILD_SHARED_LIBS BUILD_PYTHON_SUPPORT 应为 BUILD_opencv_python


Maybe I'm missing something but I'm not able to build the static libraries of opencv.

Setup:

Kubuntu 12.04

gcc 4.6.3

make 3.81

cmake 2.8.7

opencv 2.4.6.1 (last available on site)

I do all the job manually. I tried with cmake-gui with no more success.

I do what it is written.

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D WITH_QT=ON -D BUILD_SHARED_LIBRARIES=OFF ..

(I also tried with BUILD_SHARED_LIBRARIES=NO)

What I get is (for core for example):

  • libopencv_core.so
  • libopencv_core.so.2.4
  • libopencv_core.so.2.4.6
  • libopencv_core_pch_dephelp.a

To say the truth, I expected libopencv_core.a.

I'm a newbie with package/libs building on Linux. I'm sure there is something I did wrong but I don't know what. Also I don't want to use dynamic libraries...

Thanks for your help!

EDIT Removed the blank space between -D ... in cmake command line

Result:

-- General configuration for OpenCV 2.4.6.1 =====================================
--   Version control:               unknown
-- 
--   Platform:
--     Host:                        Linux 3.2.0-51-generic x86_64
--     CMake:                       2.8.7
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++  (ver 4.6)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG -ggdb3
--     C Compiler:                  /usr/bin/gcc
--     C flags (Release):           -fsigned-char -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG -ggdb3
--     Linker flags (Release):      
--     Linker flags (Debug):        
--     Precompiled headers:         YES
-- 
--   OpenCV modules:
--     To be built:                 core imgproc flann highgui features2d calib3d ml video objdetect contrib photo legacy gpu nonfree java python stitching superres ts videostab

...

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_PYTHON_SUPPORT
    BUILD_SHARED_LIBRARIES

I still see Built as dynamic libs?: YES and it tells me that it doesn't care about the BUILD_SHARED_LIBRARIES variable!

解决方案

Looking at OpenCV's CMakeLists.txt, it appears as if you're using the wrong names for the OpenCV CMake options.

BUILD_SHARED_LIBRARIES should be BUILD_SHARED_LIBS and BUILD_PYTHON_SUPPORT should be BUILD_opencv_python

这篇关于将OpenCV构建为静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆