opencv: Can not build Opencv statically on archLinux at all
System Information
OpenCV version: 4.7.0 Operating System / Platform: Arch Linux Compiler & compiler version: GCC 12.2.1
Detailed description
I have been trying to build opencv statically on archlinux and it seems that this is impossible, each time dynamic libraries are built instead.
I have tried to use the BUILD_SHARED_LIBS=OFF
and OpenCV_STATIC
variables, I even went inside the cmake
directory and set these manually everywhere in the source code and it still building shared libraries.
This issue is only on archlinux, Debian and MacOS seems to be building static libs with the BUILD_SHARED_LIBS
Any thoughts?
Steps to reproduce
Trying this would not work
cmake -DBUILD_SHARED_LIBS=OFF ../
Issue submission checklist
- I report the issue, it’s not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (8 by maintainers)
Perhaps these issues come from the OpenVDB library, it has several places where it sets variable in question: e.g. https://github.com/AcademySoftwareFoundation/openvdb/blob/e7ec2a716eac2bd03fc491d2d9639c6d5afd61cf/cmake/FindOpenVDB.cmake#L500 Somehow it got included into the build process, OpenCV does not use it, some other library should be involved here.
Hello, I couldn’t reproduce this issue on ubuntu 23.04 with cmake 3.26.1. So I feel this problem is not related with cmake version.
We need a more information to investigate/resolve this issue. If BUILD_SHARED_LIBS=OFF is ignored, we want to detect what lines makes it. Please could you try it ?
I prepared this snippet (Line 481 and 483), which is shown current line number in CMakeList.txt and show BUILD_SHARED_LIBS variable.
All my test result are here. LINE 17 means initial value, LINE 1163 means finally value. In this case, BUILD_SHARED_LIBS parameter has been propagated from terminal/console to cmake correctly.
Case1: Default
Case 2: Defined with “ON”
Case 3: Defined with “OFF”
All changes to debug CMakeList.txt
Apparently OpenVDB comes as VTK dependency (https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/OpenVDB/CMakeLists.txt). Disable VTK in OpenCV if you don’t need it (
WITH_VTK=OFF
) or maybe disabling it in VTK would help (VTK_MODULE_ENABLE_VTK_IOOpenVDB=NO
)?@mshabunin Sorry for being too late on this, I was really busy. I managed to run the command and extract the log related to
BUILD_SHARED_LIBS
in a specific file that is way much reduced in size.This is the command I ran:
reduced_trace.log
I have done what has been requested by adding the debug message as it should be, here is my output:
case 1 Default:
Case 2: Defined with “ON”
Case 3: Defined with “OFF”