Build Lapack 3.5.0 dll on Window 10 with MinGW - tingxingdong/clBLAS-private GitHub Wiki
Environment: MinGW, CMAKE 3.4.0, VS 2015 IDEs. I build for x64 architecture.
-
Download the lapack.tgz from the netlib website and unzip.
-
Download CMAKE and install it on your machine.
-
Download MinGW-w64 and install it on your machine. Choose "x86-64" for the architecture on the pop-up window when installing MinGW-w64.
-
Put the GNU runtime directory in your PATH. I added C:\Program Files\mingw-w64\x86_64-5.2.0-posix-seh-rt_v4-rev1\mingw64\bin in my PATH. I will use 'GNU_PATH' to indicate my GNU compiler path in the following.
-
Open CMAKE
-
-
- Point to your lapack-3.5.0 folder as the source code folder
-
-
- 2 Point to a new folder where you want the build to be (not the same is better)
-
- 3 Click configure, check the install path if you want to have the libraries and includes in a particular location. Choose "MinGW Makefiles" as the generator in the pop-up window.
-
- 4 Click "Specify native compilers" and indicate the path to the Mingw compilers. For x64, on my machine, it is "C:/GNU_PATH/x86_64-w64-mingw32-gfortran.exe" and the C compiler is "C:/GNU_PATH/bin/x86_64-w64-mingw32-gcc.exe"
-
- 5 Set the 'BUILD_SHARED_LIBS' option to ON.
-
- 6 Set the 'CMAKE_GNUtoMS' option to ON.
-
- 7 Set the 'CMAKE_GNUtoMS_VCVARS' to the vcvar32.bat file located in your VS folder. On my computer, it is C:/Program Files(x86)/Windows Visual Studio 14.0/VC/bin/vcvar32.bat. Otherwise, it won't generated liblapack.lib required by the VS.
-
- 8 if you want to build the LAPACKE library, set the 'LAPACKE' option to ON.
-
- 9 Click again configure until everything becomes white
-
- 10 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:/GNU_PATH/mingw32-make.exe"
-
Type "C:/GNU_PATH/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. Do not forget to consult also the LAPACKE User Guide.