Ask Your Question

Compiling opencv 412 with Python 3 module enabled

asked 2019-12-03 09:21:59 -0500

Vytau gravatar image

updated 2019-12-03 09:37:39 -0500

berak gravatar image

I keep trying to compile opencv with python 3.7 support. I use this configuration (under). I keep getting this error:

LINK : fatal error LNK1104: cannot open file 'python37_d.lib' [C:\lib\Build\opencv\modules\python3\opencv_python3.vcxproj]
I got tired and gave it the library it is wining for: DPYTHON_LIBRARY=C:/Python/libs/python37_d.lib
Then I got the error 
LINK : fatal error LNK1104: cannot open file 'python37.lib' [C:\lib\Build\opencv\modules\python3\opencv_python3.vcxproj]

How to make this work, any ideas?

Configuration (

-DBUILD_NEW_PYTHON_SUPPORT=ON -DBUILD_opencv_python3=ON -D HAVE_opencv_python3=ON \
-DPYTHON_EXECUTABLE=C:/Python/python.exe -DPYTHON_INCLUDE_DIRS=C:/Python/include -DPYTHON_INCLUDE_LIBRARIES=C:/Python/libs -DPYTHON_LIBRARY=C:/Python/libs/python37.lib \
cmake -G"$CMAKE_CONFIG_GENERATOR" $CMAKE_OPTIONS -DOPENCV_EXTRA_MODULES_PATH="$myRepo"/opencv_contrib/modules -DCMAKE_INSTALL_PREFIX="$myRepo"/install/"$RepoSource" "$myRepo/$RepoSource"
echo "************************* $Source_DIR -->debug"
cmake --build .  --config debug
echo "************************* $Source_DIR -->release"
cmake --build .  --config release
cmake --build .  --target install --config release
cmake --build .  --target install --config debug
edit retag flag offensive close merge delete



afaik, there are no python debug libs on win, so you can only build in release mode. can you try to comment those

cmake --build .  --config debug
cmake --build .  --target install --config debug

lines ?

berak gravatar imageberak ( 2019-12-03 09:50:40 -0500 )edit

Yes, thank you, I did this and it worked!

Vytau gravatar imageVytau ( 2019-12-04 07:35:50 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-12-03 10:32:37 -0500

A workaround is to comment out the debug parts of pyconfig.h as described here.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-12-03 09:21:59 -0500

Seen: 819 times

Last updated: Dec 03 '19