-
Notifications
You must be signed in to change notification settings - Fork 849
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
How to build cv2 in debug non-optimized mode? #424
Comments
Alright I came up with an extremely hacky solution that does work. Someone more used to I ran the build as follows choosing to keep all temporary build files:
Then I swallowed up the output into
Then I extracted and transformed all commands involving the build:
Finally executing
After copying that file into the directory |
I believe Because of the However, you could try running:
but then pip wheel command docs: https://pip.pypa.io/en/stable/reference/pip_wheel/#customising-the-build OpenCV build information: https://docs.opencv.org/master/db/d05/tutorial_config_reference.html |
Thanks for the help, but when I tried
Given that I only want to do this for investigative/understanding work, my hack seems like the easiest approach for the moment since it already works. I'm guessing there aren't that many people who find themselves in my boat. But thanks for the response! |
There's one additional way of doing this via the
Please note that you must install at least |
I just checked and this worked for me on Linux too. Might be worth adding something in the main readme about this (which I can try to remember to do), but other than that seems good. Thanks! |
C:\temp\opencv-python>python setup.py bdist_wheel --build-type=Debug An error occurred while building with CMake. |
Having the same issue as @black13. I just need the debug output from https://github.com/opencv/opencv/blob/1363496c1106606684d40447f5d1149b2c66a9f8/modules/videoio/src/cap_dshow.cpp#L302 but looks like to get this I need to get a debug build of python including debug builds of opencv-python dependencies. Is this true? |
You should really only need a debug build of the library you're interested in, but it can be a bit tricky. The method I used in my post should work for Linux, but if you're on Windows like black13, I can't really help you with the details. |
@letmaik @black13 The error you are seeing is caused by the missing Python debug binaries. We can see clearly from the output that the linker is trying to link against the Python debug binary (note the _d):
See for example this issue: opencv/opencv#7395 You must install the debug binaries. This can be done via the official Python installer as documented here (customize installation): https://docs.python.org/3/using/windows.html#installation-steps
Edit: You can run the installer also without UI if needed: https://docs.python.org/3/using/windows.html#installing-without-ui |
@skvark Thanks for the pointer. I tried to do that here by adding |
Scikit-build picks up the wrong path, you can change it here: https://github.com/opencv/opencv-python/blob/master/setup.py#L41 |
I hacked in the right path (upstream issue: scikit-build/scikit-build#533) and got a bit closer. It now fails during copying of the files from the CMake install folder:
Here's the log: https://ci.appveyor.com/project/letmaik/opencv-python/builds/38432602 What's weird is that the "-- Installing:" line from CMake for the .pyd is missing, compared to a regular build like https://ci.appveyor.com/project/skvark/opencv-python/builds/36078624/job/vd96v0pmj7ai9bno?fullLog=true. EDIT: Looks like it's related to this code: https://github.com/opencv/opencv/blob/fc1a15626226609babd128e043cf7c4e32f567ca/modules/python/common.cmake#L125-L129 |
I faced the exact same issue when building wheel on linux. |
For those who just want a "python39_d.lib" (DLL) what is the option? [No desire to actually BUILD Python] |
Edit: I am working with latest commit on the opencv repo and with the tag 4.5.5 I installed a python 3.10 version with the corresponding python310_d.lib, and also attempted to create a python debug build, though it seemed to be a bigger hassle than it was worth. I couldn't get the installer debug libs to work even when opencv found the python310_d.lib, perhaps due to the problem described above with scikit? Anyways, prior to this I did something like: In case the stackoverflow topic is lost, this is the minimum CMakeLists.txt for the Hough Transform example:
The only downside I see is that in addition to the target includes in above link, I have to include my I have no concrete idea why it really works, I get the same errors and warnings as when I set up for building opencv inside Visual Studio, but the fact that it does work in both |
I want to build the final cv2 shared library (e.g.
cv2.cpython-39-x86_64-linux-gnu.so
) with debug symbols and without optimizations. I have tried various strategies like editing theopencv/CMakeLists.txt
as well as running a build with something like this:No matter what I do, the final library seems to be built in Release mode and ignores my optimizations. How do I do this?
The text was updated successfully, but these errors were encountered: