Ask Your Question
0

Compiling opencv 412 with Python 3 module enabled

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

Vytau gravatar image

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

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 (install.sh):

CMAKE_OPTIONS='-DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF \ 
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DOCS:BOOL=OFF -DWITH_CUDA:BOOL=OFF \
-DBUILD_EXAMPLES:BOOL=OFF -DINSTALL_CREATE_DISTRIB=ON \
-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 \
-DPYTHON_NUMPY_INCLUDE_DIRS=C:/Python/Lib/site-packages/numpy/core/include'
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

Comments

1

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 -0600 )edit
1

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

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

1 answer

Sort by ยป oldest newest most voted
2

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

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

Stats

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

Seen: 1,331 times

Last updated: Dec 03 '19