$ $ 我仍然看到构建为动态库:,它告诉我, 解决方案查看 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.04gcc 4.6.3make 3.81cmake 2.8.7opencv 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.solibopencv_core.so.2.4libopencv_core.so.2.4.6libopencv_core_pch_dephelp.aTo 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 lineResult:-- 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 doneCMake Warning: Manually-specified variables were not used by the project: BUILD_PYTHON_SUPPORT BUILD_SHARED_LIBRARIESI 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构建为静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-21 05:15