Install error for Visual Studio 2019 - cmake error: could not create named generator visual studio 16 2019 win64

Thanks for setting up this new forum.

I’ve been having problems with the install for Visual Studio tutorial for “Installation by Using git-bash (version>=2.14.1) and cmake (version >=3.9.1)”

I kept getting this error:
cmake error: could not create named generator visual studio 16 2019 win64

After reading up on numerous boards, etc, I found a solution that worked for me. If your having trouble getting the installOCV.sh to run properly, two lines need to be changed.

The CMAKE_CONFIG_GENERATOR line should read:
CMAKE_CONFIG_GENERATOR=“Visual Studio 16 2019”

and add -A x64 to the following line after “$CMAKE_CONFIG_GENERATOR”:

cmake -G “$CMAKE_CONFIG_GENERATOR” -A x64 $CMAKE_OPTIONS -DOPENCV_EXTRA_MODULES_PATH="$myRepo"/opencv_contrib/modules -DCMAKE_INSTALL_PREFIX="$myRepo"/install/"$RepoSource" “$myRepo/$RepoSource”

This is necessary because MSVS change the platform naming conventions for MSVS 2019
https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html

Hope this helps someone. Perhaps it’s a good time to update the instructions page.

2 Likes

Windows cannot recognize to run the file installOCV.sh.

Seems that cmake option is for linux in the installOCV.sh.
What about for the windows ?.