For this tutorial, we are going to use Windows 11 in a command prompt-only fashion, compiling the library with the latest GFortran from MSYS2. In this guide, we obtain MSYS2 through winget (Microsoft's package manager).
- Have the skills needed to adapt the commands contained here for Windows 10, if it applies;
- Command prompt running as administrator opened;
- Internet connection;
- Tools:
- MSYS2;
- gfortran (latest provided by MSYS2);
- make (latest provided by MSYS2);
- git;
- cmake (>= 3.17).
According to Microsoft, the recommended way to install winget (a package manager for Windows maintained by Microsoft) goes through the Microsoft Store, distributed within the App Installer package. So, go ahead and install it.
Note
On my personal experience using a fresh Windows 11 installation for this guide, if you download and install all the Windows updates and restart your computer the many times required, winget will get installed in the process.
You can check that winget got properly installed if the search command works well on cmd once you answer Y when asked. For example, running a search winget search MSYS2 for MSYS2 on winget, you would receive an output like this:
Tip
You might skip the steps for the tools that you already have installed on your computer.
Note
Although you can opt to install all the tools directly from MSYS2 (they have packages for each tool on their repositories), we are going to build minpack in a standard command prompt, i.e., out of MSYS2 shell.
- (Optional if you have MSYS2) Install MSYS2, update core packages and tools
-
The first step is the installation on MSYS2 on your computer, in case you don't have it yet
winget install --id MSYS2.MSYS2 --source winget --accept-package-agreements --accept-source-agreements --silent
-
(Optional, but recommended) Update MSYS2 utilities and packages running the same command twice:
%homedrive%\msys64\usr\bin\bash.exe -lc "pacman -Syuu --noconfirm --overwrite *" %homedrive%\msys64\usr\bin\bash.exe -lc "pacman -Syuu --noconfirm --overwrite *"
-
Warning
%homedrive% is a system environment variable on Windows that points to the drive letter (C: if you didn't perform a custom Windows install). If you have a standard MSYS2 installation, it gets installed at %homedrive%\msys64, which expands to C:\msys64. You might change it above in case you have MSYS2 elsewhere.
-
Install GFortran + GNU Make targeting x86_64 architecture from MSYS2
%homedrive%\msys64\usr\bin\bash.exe -lc "pacman -S mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-make --noconfirm --overwrite *"
It is a good idea to test the installation of
gfortranandmakeby running the command%homedrive%\msys64\mingw64\bin\gfortran.exe --version %homedrive%\msys64\mingw64\bin\mingw32-make.exe --version
-
(Optional if you have git) Install git
winget install --id Git.Git --source winget --accept-package-agreements --accept-source-agreements --silent
-
(Optional if you have CMake >= 3.17) Install CMake
winget install --id Kitware.CMake --source winget --accept-package-agreements --accept-source-agreements --silent
Important
If you installed git and cmake above, these tools are not on your system environment PATH variable until you launch a new fresh command prompt. So, it is a wise choice to close the current command prompt.
-
Launch a fresh vanilla (admin rights not needed) command prompt.
-
Place the directory of MSYS2 tools (
gfortran+make) in the system environment PATH variable in order for CMake to find themset PATH=%homedrive%\msys64\mingw64\bin;%PATH%
-
Test that all the needed tools are available on your command prompt
gfortran.exe --version mingw32-make.exe --version git --version cmake --version
-
Set a cmd variable to hold a working directory. In sequence, create that directory, and then change dir to this newly created working dir
set working_dir=%homedrive%\minpack-builder-gfortran-guide mkdir %working_dir% cd %working_dir%
-
Set cmd variables for the build and install directories
set BUILD_DIR=%working_dir%\build-gfortran set INSTALL_DIR=%working_dir%\local-install-gfortran
Note
If your %homedrive% variable points to C:, we are going for a local installation at C:\minpack-builder-gfortran-guide\local-install-gfortran, building the package at C:\minpack-builder-gfortran-guide\build-gfortran.
-
Clone minpack-builder by running
git clone https://github.com/luau-project/minpack-builder
-
By default, minpack-builder downloads (optional param
USE_DOWNLOADisON) minpack source code to the same directory of minpack-builder (provided by optional paramDOWNLOAD_DIR).cmake -G "MinGW Makefiles" --install-prefix "%INSTALL_DIR%" -S minpack-builder -B "%BUILD_DIR%"
Note
If the optional param CMAKE_BUILD_TYPE is not specified, a Release build is configured.
-
Review the configuration summary and proceed to build
-
Build the library.
cmake --build "%BUILD_DIR%"
Note
By default, only the shared library is built. Using the GCC toolchain provided by MSYS2 on Windows, you can even build both shared and static libraries in the same step. For that, you can also build the static library by adding -DBUILD_STATIC_LIBS=ON in the configuration step.







