Skip to content

Latest commit

 

History

History
193 lines (143 loc) · 11.1 KB

File metadata and controls

193 lines (143 loc) · 11.1 KB

Build and Install on Windows 11 (Intel Fortran Compiler - ifx)

For this tutorial, we are going to use Windows 11 mostly in a command prompt-only fashion, compiling the library with Intel Fortran Compiler (ifx) acquired through winget (Microsoft's package manager).

Note

At the time of writing this guide, the latest Intel Fortran Compiler (ifx), which is ifx 2024.1, requires Visual Studio 2022 or 2019 native build tools to work nicely.

Table of Contents

Requirements

  1. Have the skills needed to adapt the commands contained here for Windows 10, if it applies;
  2. Command prompt running as administrator opened;
  3. Internet connection;
  4. Tools:
    • Microsoft Visual C/C++ (MSVC) build tools for native C/C++ x86/x64 development (latest) + Windows SDK (suitable for your target platform);
    • ifx (latest version available on winget repositories);
    • git;
    • cmake (>= 3.17).

Pre-installation steps

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

winget search "visual studio"

works well on cmd once you answer Y when asked. You would receive an output like this:

Screenshot from 2024-05-05 10-54-50

Install the required tools

Tip

You might skip the steps for the tools that you already have installed on your computer.

  1. Close any Visual Studio instances opened on your machine;

  2. Open a command prompt running as administrator to avoid permission issues when installing the tools required here;

    Screenshot from 2024-05-05 12-27-04

  3. Set a variable to hold the path to a working directory, create that directory, and then change dir to this new directory

    set working_dir=%homedrive%\minpack-builder-guide
    mkdir %working_dir%
    cd %working_dir%

    Screenshot from 2024-05-05 12-28-57

Note

%homedrive% is a Windows environment variable that expands to your root letter (C: in case you performed a vanilla Windows install). For instance, if your home drive is D:, then D:\minpack-builder-guide will be used as working directory.

  1. Make sure to have installed both MSVC Build Tools 2022 for native C/C++ x86/x64 development, and a Windows SDK:
    • If you don't have Visual Studio 2022 installed and just want MSVC native C/C++ compilers for x86/x64, install them with the command below depending on the Windows version that you are targeting
      • Windows 10
        winget install --id Microsoft.VisualStudio.2022.BuildTools --source winget --silent --override "--quiet --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.18362"
      • Windows 11
        winget install --id Microsoft.VisualStudio.2022.BuildTools --source winget --silent --override "--quiet --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.22000"
    • Otherwise, assuming that you already have a Visual Studio 2022 instance previously installed, you can modify it to include native C/C++ x86/x64 development + Windows SDK depending on the Windows version that you are targeting:
      • Windows 10
        if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property properties.setupEngineFilePath`) do ( for /f "usebackq tokens=*" %j in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property installationPath`) do ( "%comspec%" /C ""%i" modify --quiet --installPath "%j" --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.18362" ) ) ) else ( echo "Unable to find vswhere.exe" )
      • Windows 11
        if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property properties.setupEngineFilePath`) do ( for /f "usebackq tokens=*" %j in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property installationPath`) do ( "%comspec%" /C ""%i" modify --quiet --installPath "%j" --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.22000" ) ) ) else ( echo "Unable to find vswhere.exe" )
  2. (Optional if you have ifx) Install Intel Fortran Compiler (ifx)
    winget install --id Intel.FortranCompiler --source winget --accept-package-agreements --accept-source-agreements --silent
  3. (Optional if you have git) Install git
    winget install --id Git.Git --source winget --accept-package-agreements --accept-source-agreements --silent
  4. (Optional if you have CMake >= 3.17) Install CMake
    winget install --id Kitware.CMake --source winget --accept-package-agreements --accept-source-agreements --silent

Important

You must close the command prompt, because the installed tools are not on your system environment PATH variable until you launch a new fresh command prompt.

Build and Install minpack

  1. Launch a vanilla (admin rights not needed) new fresh x64 Native Tools Command Prompt for VS 2022 to build 64-bit minpack or x86 Native Tools Command Prompt for VS 2022 to build 32-bit minpack.

    Screenshot from 2024-05-05 17-31-44

  2. Load Intel oneAPI variables to access ifx compiler

    call "%ProgramFiles(x86)%\Intel\oneAPI\setvars.bat"

    Screenshot from 2024-05-05 17-41-39

Note

If you performed the standard install for Intel Fortran Compiler, it gets installed at %ProgramFiles(x86)%\Intel\oneAPI. Change the path above if you installed somewhere else.

  1. Set again a variable to hold the path to that working directory created previously, and then change dir to the working directory

    set working_dir=%homedrive%\minpack-builder-guide
    cd %working_dir%
  2. Set cmd variables for the build and install directories

    set BUILD_DIR=%working_dir%\build-ifx
    set INSTALL_DIR=%working_dir%\local-install-ifx

Note

If your %homedrive% variable points to C:, we are going for a local installation at C:\minpack-builder-guide\local-install-ifx, building the package at C:\minpack-builder-guide\build-ifx.

  1. Clone minpack-builder by running

    git clone https://github.com/luau-project/minpack-builder

    Screenshot from 2024-05-05 17-48-51

  2. By default, minpack-builder downloads (optional param USE_DOWNLOAD is ON) minpack source code to the same directory of minpack-builder (provided by optional param DOWNLOAD_DIR).

    cmake -G "NMake Makefiles" --install-prefix "%INSTALL_DIR%" -S minpack-builder -B "%BUILD_DIR%"
    

Important

In my personal tests, building with Visual Studio generator does not work nicely in most scenarios. So, prefer to build with -G "NMake Makefiles", because it already comes bundled with Visual Studio or MSVC Build Tools. You might also want to build with Ninja generator (-G Ninja) in case you have Ninja (version >= 1.10) installed.

Note

If the optional param CMAKE_BUILD_TYPE is not specified, a Release build is configured.

  1. Review the configuration summary and proceed to build

    Screenshot from 2024-06-02 10-25-42

  2. Build the library.

    cmake --build "%BUILD_DIR%"
    

    Screenshot from 2024-06-02 10-26-30

Note

By default, only the shared library is built. You can build the static library by feeding -DBUILD_STATIC_LIBS=ON in the configuration step. However, in my personal tests, the generated static library minpack.lib will ask you where Intel specific libraries are stored once you use it on other projects. Thus, in order to keep things simple here, prefer to build only the shared library.

Important

Unlike Linux, on Windows you cannot build both shared and static libraries in the same step, because the library name collides (minpack.lib). Then, you can only build one version at a time. Be aware that if you install both in the same directory, the latter will map to minpack.lib.

  1. Install the library

    cmake --install "%BUILD_DIR%"
    

    Screenshot from 2024-06-02 10-27-08

Important

By the end of this guide, you have got a working minpack shared library (minpack.dll) installed on your computer. The final minpack.dll depends on Intel Fortran Compiler Runtime for Windows (a ~ 36 MB windows installer which expands to 144 MB once installed). In order to use minpack.dll built here in a standalone manner with Intel Fortran Compiler (ifx), or redistribute to end users, you have to install Intel Fortran Compiler Runtime for Windows https://www.intel.com/content/www/us/en/developer/articles/tool/compilers-redistributable-libraries-by-version.html depending on the ifx version you have installed (2024.1 for this guide), or guide your end users to install it. In the future, since most likely these links will change and become obsolete, look for Intel Fortran Compiler Runtime for Windows.


Documentation