Build Instructions to create LAPACK and LAPACKE 3.5.0 dlls for Windows with MinGW
Requirements: MinGW, CMAKE, VS IDEs
- Download the lapack.tgz from the netlib website and unzip.
- Download CMAKE and install it on your machine.
- Download MinGW 32 bits or MinGW-w64 and install it on your machine.
- 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.
- 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
- 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
几点NOTEs:
1. 这次是编译armadillo库时用到了Lapack库,编译的是3.6.0版本,MingW-w64用4.8.0
2. 编译得到了bin,include,lib的文件夹,MingW64默认不生成供VS使用的lib,所以需要打开CMAKE_GNUtoMS
3. 得到的Lapack库需要全部拷贝到MingW目录下,以便编译armadillo库时CMake能够找到相应的Lapack库。