Ask Your Question
0

Compiling opencv 412 with Python 3 module enabled

asked Dec 3 '19

Vytau gravatar image

updated Dec 3 '19

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
Preview: (hide)

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 (Dec 3 '19)edit
1

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

Vytau gravatar imageVytau (Dec 4 '19)edit

1 answer

Sort by » oldest newest most voted
2

answered Dec 3 '19

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

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Dec 3 '19

Seen: 1,511 times

Last updated: Dec 03 '19