Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building OpenCV as static libraries

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!

like image 940
dom_beau Avatar asked Aug 14 '13 02:08

dom_beau


1 Answers

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

like image 134
Fraser Avatar answered Sep 17 '22 10:09

Fraser