How do you build OpenCV with LAPACK on Windows 10 via CMake?

asked 2018-02-12 03:48:41 -0600

sid311 gravatar image

updated 2018-02-12 04:10:53 -0600


I've been having trouble getting CMake to cooperate when telling it to build with LAPACK on Windows 10.

I've tried downloading the prebuilt files from LAPACK for Windows.

I downloaded the files that correspond to version 3.7.0 that are supposedly for the Intel compilers, which I have.

However, I am unsure what files I am supposed to point CMake to. To the DLLs or the LIBs?

I followed some advice from here that says to install OpenBLAS, which I did via vcpkg. I pointed CMake to the appropriate file and location but I receive a complaint from CMake:

can't build lapack check code. this lapack version is not supported.

This happens with the prebuilt libraries as well as libraries built from scratch, which I did using the Intel C and Fortran compilers and instructions from the LAPACK for Windows website mentioned above (which is version 3.8.0).

Maybe the new OpenBLAS doesn't work with this version? What do I need; BLAS or OpenBLAS? What do I point to?

Any help would be appreciated.

edit retag flag offensive close merge delete


Please remove screen copy. You can use mkl

LBerger gravatar imageLBerger ( 2018-02-12 03:54:28 -0600 )edit

Right, but how to set that up?

For LAPACK, I've pointed to mkl_lapack95_lp64.lib, and for BLAS mkl_blas95_lp64.lib, both located in 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.1.156\windows\mkl\lib\intel64_win'

For the LAPACK includes folder, I've pointed to 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.1.156\windows\mkl\include' were a bunch of headers reside.

CMake says:

A library with BLAS API found. A library with LAPACK API not found. Please specify library location.

In that includes folder, there is mkl_lapack.h, mkl_lapacke.h, mkl_cblas.h, etc but I don't think the included setup CMake files know how to recognized them. :(

sid311 gravatar imagesid311 ( 2018-02-12 17:54:08 -0600 )edit

Ok, followed the instructions I found here and here.

Everything auto populates for LAPACK when manually setting the files and locations for MKL, all except LAPACK_LIBRARIES. It is empty and there is no way to select files or folders. >:(

I'll keep digging...

sid311 gravatar imagesid311 ( 2018-02-12 23:18:26 -0600 )edit

OK I think I got it to work, and by work I mean all the configurations look right and I get reassuring output from CMake.

I followed the directions in my previous post only I didn't need to modify the OpenCVFindMKL.cmake file. Also I am not using CUDA.

Before running CMake, I set the following system variables and added them to my path:

INTEL_TBB = C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\redist\intel64_win\tbb\vc_mt

MKLROOT = C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.1.156\windows\mkl
sid311 gravatar imagesid311 ( 2018-02-13 00:26:04 -0600 )edit

Then I invoked CMake from the command prompt using:

C:\WINDOWS\system32>"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\tbb\bin\tbbvars.bat" intel64

C:\WINDOWS\system32>"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.1.156\windows\mkl\bin\mklvars.bat" intel64

C:\WINDOWS\system32>"C:\Program Files\CMake\bin\cmake-gui"

I chose 'Visual Studio 15 2017 Win64' as my generator and I chose the Intel C/C++/Fortran compiler as my native compiler(s) but I don't think CMake listened to me.

I'll generate and build. hope it works.

sid311 gravatar imagesid311 ( 2018-02-13 00:28:14 -0600 )edit

I don't know intel C++ compiler but I think you must choose intel in cmake generator and not vs (vs is just an ide when you choose intel)

LBerger gravatar imageLBerger ( 2018-02-13 04:58:23 -0600 )edit

Intel's compilers don't show up as an option to choose as a generator. I am able to configure, generate and build using VS 15 and native compilers though. However, there is something wrong with my Java and Python wrappers, but I suppose that's a topic for another thread. I'm still building and will start another thread if need be. Thank you.

sid311 gravatar imagesid311 ( 2018-02-14 19:58:58 -0600 )edit
LBerger gravatar imageLBerger ( 2018-02-15 01:37:55 -0600 )edit

Doesn't seem to work for me. The guy says to add the line:

set(CMAKE_GENERATOR_TOOLSET "Intel C++ Compiler XE 14.0" CACHE STRING "Platform Toolset" FORCE)

in CMakeLists.txt but where exactly? I get an error stating that the compiler cannot be found. I assume mine is version 18.0 but I've tried 17.0 as well and no go. :/

Even using -T argument "Intel C++ Compiler XE 14.0" at the generator selection dialog box won't work. :/

sid311 gravatar imagesid311 ( 2018-02-15 02:36:02 -0600 )edit

Ok may be you can use method given here

LBerger gravatar imageLBerger ( 2018-02-15 02:51:26 -0600 )edit