-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenCVModules.cmake has wrong libraries on static windows, static standalone IPP #19282
Comments
CMake's target name is not the same as the library name. They can be different. For static distribution it is "user" responsibility to track and properly define used external dependencies (their targets) before using Unfortunately there is no
I would prefer to keep this current approach. At least as the default (to avoid breaking of existed external scripts). |
Hi. This has nothing to do with The file There is no way for an app to stop this injection. It is happening with anyone building it like me. Which as I suspect, is a very small population of people since it has to be someone building opencv for themselves as: windows, static opencv libs, ipp standalone, ipp static libs. For the 100 people in the world doing it, I'm confident that any build automation they made, will continue to work with this bug fix...or their hack to workaround this bug can be removed so it works naturally. This is a minor build bug, not a running library crash. It passes my local tests and passed all your test automation tests. Just like you preferred in aligned memory...making it work with the natural native method is better. The only workaround is to start probing every library opencv as a library lists as needing to linked, and then make a mapping of fixing the bug and inject that again into the apps cmake. Very messy and not susatainable. |
Agreed.
Just "correct" library name is not enough.
Because we don't test distribution (through "install") of static builds widely (this configuration is not well supported and rarely used). |
I believe we can fix the broken build. As it is today, it is broken...apps will not compile that use the static scenario I describe in my OP. In my experience a "broken build" is one of the most important bugs to fix. We both agree there is a small set of people that are affected. Then I suggest we fix this because few are affected, therefore if there is some bug in the fix, then again few are affected. And it is the build...not a runtime code problem. Yes, there are at least 3 issues with opencv's library injection:
I have a fix in PR for (1). I have a workaround for (2) in my CMakeLists.txt. A fix for (3) needs more thought. I recommend we make the build not break. I recommend we fix (1). Currently, it is broken for the scenario in my OP. Apps will not compile because opencv is injecting the wrong names of libraries. The only fix is my PR -- or to do very manual manipulation of app target library lists in CMake by parsing them, searching for all OpenCV libraries (which is not always known due to changes in module dependencies), then re-writing those libraries with whatever fix is needed (IPP needs "mt"). I started to write this workaround but it is so messy...I chose to fix the bug instead. If OpenCV can't inject a correct list of libraries, then it should NOT inject libraries. Make the app do it all manually. Because the fixing of wrong libraries is harder than building a known set of libraries manually. Of course...I wouldn't suggest you actually stop injecting...that would break many many people. Again this is not relevant: "...but there are no instructions how users should get this IPP's CMake config". You keep writing this and I keep telling you this is not the issues I am reporting. I think we have a language barrier occurring. How can I better explain this to you? 🤔 Apps don't load IPP. Apps don't find_package(IPP). Instead apps write Here is a sample CMakeFile.txt you can see. There is some extra things in there that I need for my specific setup. I am confident you can understand. cmake_minimum_required(VERSION 3.18)
cmake_policy(SET CMP0091 NEW) # enable Msft VC runtime library selection
project(bug19282
LANGUAGES CXX
)
set(OpenCV_STATIC ON)
find_package(
OpenCV REQUIRED
PATHS C:/repos-nobackup/opencv/.install/Debug
)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(bug19282 myapp.cpp)
target_link_libraries(bug19282 ${OpenCV_LIBS}) Look above. IPP is not involved. This is all OpenCV. OpenCV is injecting the wrong library names. And therefore the app will not compile because those libraries don't exist on the hard drive (or are the wrong type static/dynamic) causing the linker to fail. Don't compile. Just cmake configure the project, then look at |
Please read the first sense of the first my comment. For static builds is it responsibility of the user to properly configure external targets (because they are not re-distributed by OpenCV and scripts can't handle that).
It is CMake fallback behavior for missing "targets".
There are no libraries. Just CMake targets. |
Thanks for more clarity. Give me a few days to digest this and think over all we have discussed. I will definitely close/reply before Wednesday. |
I now follow the intention of OpenCV. It is technically a valid approach. However, it is harder for apps that static link since there is no "finder" written by OpenCV that matches OpenCV's specific symbolic target names. I think this is a disservice to a subset of your users. It makes them have to either: easy fix like my PR --or-- hard fix to write an entire "finder" that will match what OpenCV is outputting. Given the relationship that OpenCV has with Intel -- I suggest that your core team escalate this gap to your Intel contacts. And have them write an official Thoughts, opinions? |
I used this to work around the issue, its ugly and hardcodes the paths, but it works for me:
|
opencv built on windows, building static opencv libraries, with standalone IPP, with IPP static libraries creates wrong downstream CMake package files -- those files that are later included in applications that build with opencv as a library. These downstream package files fail to have the needed
mt
at the end of the library name.These package files are created when OpenCV is built/installed. They declare a list of libraries to be linked and downstream apps that are built with cmake use that list when
find_package(opencv)...target_link_libraries(${OpenCV_LIBS})
etc. is used. That list is incorrect. The errant list isippi
,ippcv
, etc. The correct list isippimt
,ippcvmt
, etc.Easy fix with PR I have ready.
System information (version)
Steps to reproduce
With_IPP=ON
,IPPROOT=xxxx
,BUILD_WITH_DYNAMIC_IPP=OFF
,BUILD_IPP_IW=OFF
,BUILD_SHARED_LIBS=OFF
install/Release/x64/vc16/staticlib/OpenCVModules.cmake
You will see incorrect libraries listed in (5). And a build of a downstream application will fail with libraries not found with (6)
The correct list is
Issue submission checklist
answers.opencv.org, Stack Overflow, etc and have not found solution
The text was updated successfully, but these errors were encountered: