Ask Your Question
0

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

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

sid311 gravatar image

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

Hello,

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

Comments

Please remove screen copy. You can use mkl

LBerger gravatar imageLBerger ( 2018-02-12 03:54:28 -0500 )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 -0500 )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 -0500 )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 -0500 )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 -0500 )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 -0500 )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 -0500 )edit
LBerger gravatar imageLBerger ( 2018-02-15 01:37:55 -0500 )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 -0500 )edit

Ok may be you can use method given here

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

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-02-26 02:51:41 -0500

updated 2018-02-26 03:15:18 -0500

If you have VS 2017 installed why are you trying to use the Intel Compiler, is it a requirement?

If not you should be able to achieve your objective by modifying the instructions you linked to build-compile-opencv-3-4-in-windows-with-cuda-9-0-and-intel-mkl-tbb to remove the CUDA and TBB options.

I assume you have installed MKL, if so open cmd and type

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

followed by

set "openCvSource=PATH_TO_SOURCE" set "vsEdition=Community"

making sure to set PATH_TO_SOURCE correctly.

Finally generate the VS2017 solutions

"C:\Program Files\CMake\bin\cmake.exe" -B"%openCvSource%\build_lapack" -H"%openCvSource%/" -G"Visual Studio 15 2017 Win64" -DBUILD_opencv_world=ON -DWITH_MKL=ON -DMKL_USE_MULTITHREAD=ON -DINSTALL_TESTS=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DWITH_CUDA=OFF

You can then inspect in the cmake gui as described in the post you linked to here and Lapack should be populated image description

I cannot confirm that the Lapack libraries will actually be used but I just followed the above steps and built in VS2017 Release x64 without errors.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-02-12 03:48:41 -0500

Seen: 289 times

Last updated: Feb 26