Put the GNU runtime directory in your PATH, for me I added C:\MinGW\bin (MinGW 32 bits) in my PATH (right click on your computer icon, go to properties, advanced system settings, Environment Variables, look for the PATH variable and put 'C:\MinGW\bin;' in front of its current value)
Open CMAKE
Point to your lapack-3.5.0 folder as the source code folder
Point to a new folder where you want the build to be (not the same is better)
Click configure, check the install path if you want to have the libraries and includes in a particular location.
Choose MinGW Makefiles.
Click "Specify native compilers" and indicate the path to the Mingw compilers.
For Win32, on my machine, the Fortran Compiler is "C:/MinGW/bin/mingw32-gfortran.exe", and the C compiler is "C:/MinGW/bin/mingw32-gcc.exe"
For x64, on my machine, it is "C:/mingw64/bin/x86_64-w64-mingw32-gfortran.exe" and the C compiler is "C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe" 此为64位mingw编译到32位中
For x64 build ONLY , add the variable CMAKE_SIZEOF_VOID_P and set it to 8 (string), this will force CMAKE to create the VCVARSAMD64 variable ( see post on forum) Note: CMAKE team corrected the issue, and thus this workaround won't be needed if you are using CMAKE 2.8.13 or above
Click "Specify native compilers" and indicate the path to the Mingw compilers. On my machine, it is "C:/MinGW/bin/gfortran.exe"
Set the 'BUILD_SHARED_LIBS' option to ON.
Set the 'CMAKE_GNUtoMS' option to ON.
if you want to build the LAPACKE library, set the 'LAPACKE' option to ON.
Click again configure until everything becomes white
Click generate, that will create the mingw build.
Close CMAKE
Open a cmd prompt (Click Run.. then enter cmd)
Go to your build folder using the cd command
Type C:/MinGW/bin/mingw32-make.exe 现在应该改为c:/progra~1/...........(表示program file文件夹, 由于windows命令行不支持空格,强烈吐槽微软) 博主在win10上运行居然会报错mingw8.1.0,cmake试了许多都不行,不知何故,可能是mingw的版本问题.只能在win8.1上生成好
Type C:/MinGW/bin/mingw32-make.exe test if you want to run LAPACK testings to make sure everything is ok
Your libs are in the lib folder, the dlls are in the bin folder. The resulting build will provide both GNU-format and MS-format import libraries for the DLLs.
Now you should be able to create a C application built with MSVC and linked directly to the MinGW-built LAPACK DLLs
NOTE: Your C application built with Microsoft Visual Studio and linked to the MinGW-built lapack DLLs will run but requires the GNU runtime DLLs ( both libgfortran-3.dll and libgcc_s_dw2-1.dll are needed.) from MinGW to be available. As you have the GNU runtime directory in your PATH, you should be good to go.