Files
OpenBLAS/docs/install/index.html
T
2026-05-02 21:09:37 +00:00

1988 lines
92 KiB
HTML

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="canonical" href="https://openblas.net/docs/install/">
<link rel="prev" href="..">
<link rel="next" href="../user_manual/">
<link rel="icon" href="../logo.svg">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.7.6">
<title>Install OpenBLAS - OpenBLAS</title>
<link rel="stylesheet" href="../assets/stylesheets/main.484c7ddc.min.css">
<link rel="stylesheet" href="../assets/stylesheets/palette.ab4e12ef.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
<script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr" data-md-color-scheme="slate" data-md-color-primary="blue-grey" data-md-color-accent="indigo">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#install-openblas" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href=".." title="OpenBLAS" class="md-header__button md-logo" aria-label="OpenBLAS" data-md-component="logo">
<img src="../logo.svg" alt="logo">
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
OpenBLAS
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Install OpenBLAS
</span>
</div>
</div>
</div>
<form class="md-header__option" data-md-component="palette">
<input class="md-option" data-md-color-media="" data-md-color-scheme="slate" data-md-color-primary="blue-grey" data-md-color-accent="indigo" aria-label="Switch to light mode" type="radio" name="__palette" id="__palette_0">
<label class="md-header__button md-icon" title="Switch to light mode" for="__palette_1" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
</label>
<input class="md-option" data-md-color-media="" data-md-color-scheme="default" data-md-color-primary="blue-grey" data-md-color-accent="indigo" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_1">
<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_0" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
</label>
</form>
<script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
</button>
</nav>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a href="https://github.com/OpenMathLib/OpenBLAS" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg>
</div>
<div class="md-source__repository">
GitHub
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href=".." title="OpenBLAS" class="md-nav__button md-logo" aria-label="OpenBLAS" data-md-component="logo">
<img src="../logo.svg" alt="logo">
</a>
OpenBLAS
</label>
<div class="md-nav__source">
<a href="https://github.com/OpenMathLib/OpenBLAS" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg>
</div>
<div class="md-source__repository">
GitHub
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href=".." class="md-nav__link">
<span class="md-ellipsis">
Home
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span class="md-ellipsis">
Install OpenBLAS
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
Install OpenBLAS
</span>
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#installing-with-a-package-manager" class="md-nav__link">
<span class="md-ellipsis">
Installing with a package manager
</span>
</a>
<nav class="md-nav" aria-label="Installing with a package manager">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#linux" class="md-nav__link">
<span class="md-ellipsis">
Linux
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#windows" class="md-nav__link">
<span class="md-ellipsis">
Windows
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#macos" class="md-nav__link">
<span class="md-ellipsis">
macOS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#freebsd" class="md-nav__link">
<span class="md-ellipsis">
FreeBSD
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#building-from-source" class="md-nav__link">
<span class="md-ellipsis">
Building from source
</span>
</a>
<nav class="md-nav" aria-label="Building from source">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#linux-and-macos" class="md-nav__link">
<span class="md-ellipsis">
Linux and macOS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#windows_1" class="md-nav__link">
<span class="md-ellipsis">
Windows
</span>
</a>
<nav class="md-nav" aria-label="Windows">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#visual-studio-native-windows-abi" class="md-nav__link">
<span class="md-ellipsis">
Visual Studio &amp; native Windows ABI
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#mingw-gnu-abi" class="md-nav__link">
<span class="md-ellipsis">
MinGW &amp; GNU ABI
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#windows-on-arm" class="md-nav__link">
<span class="md-ellipsis">
Windows on Arm
</span>
</a>
<nav class="md-nav" aria-label="Windows on Arm">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#generating-an-import-library" class="md-nav__link">
<span class="md-ellipsis">
Generating an import library
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#android" class="md-nav__link">
<span class="md-ellipsis">
Android
</span>
</a>
<nav class="md-nav" aria-label="Android">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#building-for-armv7" class="md-nav__link">
<span class="md-ellipsis">
Building for ARMV7
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#building-for-armv8" class="md-nav__link">
<span class="md-ellipsis">
Building for ARMV8
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#iphoneios" class="md-nav__link">
<span class="md-ellipsis">
iPhone/iOS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#harmonyos" class="md-nav__link">
<span class="md-ellipsis">
HarmonyOS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#mips" class="md-nav__link">
<span class="md-ellipsis">
MIPS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#freebsd_1" class="md-nav__link">
<span class="md-ellipsis">
FreeBSD
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#cortex-m" class="md-nav__link">
<span class="md-ellipsis">
Cortex-M
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../user_manual/" class="md-nav__link">
<span class="md-ellipsis">
User manual
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../extensions/" class="md-nav__link">
<span class="md-ellipsis">
Extensions
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../developers/" class="md-nav__link">
<span class="md-ellipsis">
Developer manual
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../build_system/" class="md-nav__link">
<span class="md-ellipsis">
Build system
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../runtime_variables/" class="md-nav__link">
<span class="md-ellipsis">
Runtime variables
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../distributing/" class="md-nav__link">
<span class="md-ellipsis">
Redistributing OpenBLAS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../ci/" class="md-nav__link">
<span class="md-ellipsis">
CI jobs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../about/" class="md-nav__link">
<span class="md-ellipsis">
About
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../faq/" class="md-nav__link">
<span class="md-ellipsis">
FAQ
</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#installing-with-a-package-manager" class="md-nav__link">
<span class="md-ellipsis">
Installing with a package manager
</span>
</a>
<nav class="md-nav" aria-label="Installing with a package manager">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#linux" class="md-nav__link">
<span class="md-ellipsis">
Linux
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#windows" class="md-nav__link">
<span class="md-ellipsis">
Windows
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#macos" class="md-nav__link">
<span class="md-ellipsis">
macOS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#freebsd" class="md-nav__link">
<span class="md-ellipsis">
FreeBSD
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#building-from-source" class="md-nav__link">
<span class="md-ellipsis">
Building from source
</span>
</a>
<nav class="md-nav" aria-label="Building from source">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#linux-and-macos" class="md-nav__link">
<span class="md-ellipsis">
Linux and macOS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#windows_1" class="md-nav__link">
<span class="md-ellipsis">
Windows
</span>
</a>
<nav class="md-nav" aria-label="Windows">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#visual-studio-native-windows-abi" class="md-nav__link">
<span class="md-ellipsis">
Visual Studio &amp; native Windows ABI
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#mingw-gnu-abi" class="md-nav__link">
<span class="md-ellipsis">
MinGW &amp; GNU ABI
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#windows-on-arm" class="md-nav__link">
<span class="md-ellipsis">
Windows on Arm
</span>
</a>
<nav class="md-nav" aria-label="Windows on Arm">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#generating-an-import-library" class="md-nav__link">
<span class="md-ellipsis">
Generating an import library
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#android" class="md-nav__link">
<span class="md-ellipsis">
Android
</span>
</a>
<nav class="md-nav" aria-label="Android">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#building-for-armv7" class="md-nav__link">
<span class="md-ellipsis">
Building for ARMV7
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#building-for-armv8" class="md-nav__link">
<span class="md-ellipsis">
Building for ARMV8
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#iphoneios" class="md-nav__link">
<span class="md-ellipsis">
iPhone/iOS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#harmonyos" class="md-nav__link">
<span class="md-ellipsis">
HarmonyOS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#mips" class="md-nav__link">
<span class="md-ellipsis">
MIPS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#freebsd_1" class="md-nav__link">
<span class="md-ellipsis">
FreeBSD
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#cortex-m" class="md-nav__link">
<span class="md-ellipsis">
Cortex-M
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1 id="install-openblas">Install OpenBLAS</h1>
<p>OpenBLAS can be installed through package managers or from source. If you only
want to use OpenBLAS rather than make changes to it, we recommend installing a
pre-built binary package with your package manager of choice.</p>
<p>This page contains an overview of installing with package managers as well as
from source. For the latter, see <a href="#building-from-source">further down on this page</a>.</p>
<h2 id="installing-with-a-package-manager">Installing with a package manager</h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Almost every package manager provides OpenBLAS packages; the list on this
page is not comprehensive. If your package manager of choice isn't shown
here, please search its package database for <code>openblas</code> or <code>libopenblas</code>.</p>
</div>
<h3 id="linux">Linux</h3>
<p>On Linux, OpenBLAS can be installed with the system package manager, or with a
package manager like <a href="https://docs.conda.io/en/latest/">Conda</a>
(or alternative package managers for the conda-forge ecosystem, like
<a href="https://mamba.readthedocs.io/en/latest/">Mamba</a>,
<a href="https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html">Micromamba</a>,
or <a href="https://pixi.sh/latest/#windows-installer">Pixi</a>),
<a href="https://spack.io/">Spack</a>, or <a href="https://nixos.org/">Nix</a>. For the latter set of
tools, the package name in all cases is <code>openblas</code>. Since package management in
quite a few of these tools is declarative (i.e., managed by adding <code>openblas</code>
to a metadata file describing the dependencies for your project or
environment), we won't attempt to give detailed instructions for these tools here.</p>
<p>Linux distributions typically split OpenBLAS up in two packages: one containing
the library itself (typically named <code>openblas</code> or <code>libopenblas</code>), and one containing headers,
pkg-config and CMake files (typically named the same as the package for the
library with <code>-dev</code> or <code>-devel</code> appended; e.g., <code>openblas-devel</code>). Please keep
in mind that if you want to install OpenBLAS in order to use it directly in
your own project, you will need to install both of those packages.</p>
<p>Distro-specific installation commands:</p>
<div class="tabbed-set tabbed-alternate" data-tabs="1:4"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Debian/Ubuntu/Mint/Kali</label><label for="__tabbed_1_2">openSUSE/SLE</label><label for="__tabbed_1_3">Fedora/CentOS/RHEL</label><label for="__tabbed_1_4">Arch/Manjaro/Antergos</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<p><div class="highlight"><pre><span></span><code>$<span class="w"> </span>sudo<span class="w"> </span>apt<span class="w"> </span>update
$<span class="w"> </span>sudo<span class="w"> </span>apt<span class="w"> </span>install<span class="w"> </span>libopenblas-dev
</code></pre></div>
OpenBLAS can be configured as the default BLAS through the <code>update-alternatives</code> mechanism:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>sudo<span class="w"> </span>update-alternatives<span class="w"> </span>--config<span class="w"> </span>libblas.so.3
</code></pre></div>
</div>
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>sudo<span class="w"> </span>zypper<span class="w"> </span>refresh
$<span class="w"> </span>sudo<span class="w"> </span>zypper<span class="w"> </span>install<span class="w"> </span>openblas-devel
</code></pre></div>
<p>OpenBLAS can be configured as the default BLAS through the <code>update-alternatives</code> mechanism:
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>sudo<span class="w"> </span>update-alternatives<span class="w"> </span>--config<span class="w"> </span>libblas.so.3
</code></pre></div></p>
</div>
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>dnf<span class="w"> </span>check-update
$<span class="w"> </span>dnf<span class="w"> </span>install<span class="w"> </span>openblas-devel
</code></pre></div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Fedora does not ship the pkg-config files for OpenBLAS. Instead, it wants you to
link against <a href="https://www.mpi-magdeburg.mpg.de/projects/flexiblas">FlexiBLAS</a> (which
uses OpenBLAS by default as its backend on Fedora), which you can install with:</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>dnf<span class="w"> </span>install<span class="w"> </span>flexiblas-devel
</code></pre></div>
</div>
<p>For CentOS and RHEL, OpenBLAS packages are provided via the <a href="https://fedoraproject.org/wiki/EPEL">Fedora EPEL repository</a>.
After adding that repository and its repository keys, you can install
<code>openblas-devel</code> with either <code>dnf</code> or <code>yum</code>.</p>
</div>
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>sudo<span class="w"> </span>pacman<span class="w"> </span>-S<span class="w"> </span>openblas
</code></pre></div>
</div>
</div>
</div>
<h3 id="windows">Windows</h3>
<div class="tabbed-set tabbed-alternate" data-tabs="2:3"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><input id="__tabbed_2_2" name="__tabbed_2" type="radio" /><input id="__tabbed_2_3" name="__tabbed_2" type="radio" /><div class="tabbed-labels"><label for="__tabbed_2_1">Conda-forge</label><label for="__tabbed_2_2">vcpkg</label><label for="__tabbed_2_3">OpenBLAS releases</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<p>OpenBLAS can be installed with <code>conda</code> (or <code>mamba</code>, <code>micromamba</code>, or
<code>pixi</code>) from conda-forge:
<div class="highlight"><pre><span></span><code>conda install openblas
</code></pre></div></p>
<p>Conda-forge provides a method for switching the default BLAS implementation
used by all packages. To use that for OpenBLAS, install <code>libblas=*=*openblas</code>
(see <a href="https://conda-forge.org/docs/maintainer/knowledge_base/#switching-blas-implementation">the docs on this mechanism</a>
for more details).</p>
</div>
<div class="tabbed-block">
<p>OpenBLAS can be installed with vcpkg:
<div class="highlight"><pre><span></span><code># In classic mode:
vcpkg install openblas
# Or in manifest mode:
vcpkg add port openblas
</code></pre></div></p>
</div>
<div class="tabbed-block">
<p>Windows is the only platform for which binaries are made available by the
OpenBLAS project itself. They can be downloaded from the GitHub
Releases](https://github.com/OpenMathLib/OpenBLAS/releases) page. These
binaries are built with MinGW, using the following build options:
<div class="highlight"><pre><span></span><code>NUM_THREADS=64 TARGET=GENERIC DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 CONSISTENT_FPCSR=1 INTERFACE=0
</code></pre></div>
There are separate packages for x86-64 and x86. The zip archive contains
the include files, static and shared libraries, as well as configuration
files for getting them found via CMake or pkg-config. To use these
binaries, create a suitable folder for your OpenBLAS installation and unzip
the <code>.zip</code> bundle there (note that you will need to edit the provided
<code>openblas.pc</code> and <code>OpenBLASConfig.cmake</code> to reflect the installation path
on your computer, as distributed they have "win" or "win64" reflecting the
local paths on the system they were built on).</p>
<p>Note that the same binaries can be downloaded
<a href="http://sourceforge.net/projects/openblas/files">from SourceForge</a>; this is
mostly of historical interest.</p>
</div>
</div>
</div>
<h3 id="macos">macOS</h3>
<p>To install OpenBLAS with a package manager on macOS, run:</p>
<div class="tabbed-set tabbed-alternate" data-tabs="3:3"><input checked="checked" id="__tabbed_3_1" name="__tabbed_3" type="radio" /><input id="__tabbed_3_2" name="__tabbed_3" type="radio" /><input id="__tabbed_3_3" name="__tabbed_3" type="radio" /><div class="tabbed-labels"><label for="__tabbed_3_1">Homebrew</label><label for="__tabbed_3_2">MacPorts</label><label for="__tabbed_3_3">Conda-forge</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code>%<span class="w"> </span>brew<span class="w"> </span>install<span class="w"> </span>openblas
</code></pre></div>
</div>
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code>%<span class="w"> </span>sudo<span class="w"> </span>port<span class="w"> </span>install<span class="w"> </span>OpenBLAS-devel
</code></pre></div>
</div>
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code>%<span class="w"> </span>conda<span class="w"> </span>install<span class="w"> </span>openblas
</code></pre></div>
<p>Conda-forge provides a method for switching the default BLAS implementation
used by all packages. To use that for OpenBLAS, install <code>libblas=*=*openblas</code>
(see <a href="https://conda-forge.org/docs/maintainer/knowledge_base/#switching-blas-implementation">the docs on this mechanism</a>
for more details).</p>
</div>
</div>
</div>
<h3 id="freebsd">FreeBSD</h3>
<p>You can install OpenBLAS from the FreeBSD <a href="https://www.freebsd.org/ports/index.html">Ports collection</a>:
<div class="highlight"><pre><span></span><code>pkg install openblas
</code></pre></div></p>
<h2 id="building-from-source">Building from source</h2>
<p>We recommend download the latest <a href="https://github.com/OpenMathLib/OpenBLAS/releases">stable version</a>
from the GitHub Releases page, or checking it out from a git tag, rather than a
dev version from the <code>develop</code> branch.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>The User manual contains <a href="../user_manual/#compiling-openblas">a section with detailed information on compiling OpenBLAS</a>,
including how to customize builds and how to cross-compile. Please read
that documentation first. This page contains only platform-specific build
information, and assumes you already understand the general build system
invocations to build OpenBLAS, with the specific build options you want to
control multi-threading and other non-platform-specific behavior).</p>
</div>
<h3 id="linux-and-macos">Linux and macOS</h3>
<p>Ensure you have C and Fortran compilers installed, then simply type <code>make</code> to compile the library.
There are no other build dependencies, nor unusual platform-specific
environment variables to set or other system setup to do.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>When building in an emulator (KVM, QEMU, etc.), please make sure that the combination of CPU features exposed to
the virtual environment matches that of an existing CPU to allow detection of the CPU model to succeed.
(With <code>qemu</code>, this can be done by passing <code>-cpu host</code> or a supported model name at invocation).</p>
</div>
<h3 id="windows_1">Windows</h3>
<p>We support building OpenBLAS with either MinGW or Visual Studio on Windows.
Using MSVC will yield an OpenBLAS build with the Windows platform-native ABI.
Using MinGW will yield a different ABI. We'll describe both methods in detail
in this section, since the process for each is quite different.</p>
<h4 id="visual-studio-native-windows-abi">Visual Studio &amp; native Windows ABI</h4>
<p>For Visual Studio, you can use CMake to generate Visual Studio solution files;
note that you will need at least CMake 3.11 for linking to work correctly).</p>
<p>Note that you need a Fortran compiler if you plan to build and use the latest version
of the LAPACK functions included with OpenBLAS. (If you do not have a Fortran compiler
installed, you can build an older version of the LAPACK sources that has been converted
to C - but its performance will likely be slower and accuracy may be poorer too.)
The sections below describe using either
<code>flang</code> as an add-on to clang/LLVM or <code>gfortran</code> as part of MinGW for this
purpose. If you want to use the Intel Fortran compiler (<code>ifort</code> or <code>ifx</code>) for
this, be sure to also use the Intel C compiler (<code>icc</code> or <code>icx</code>) for building
the C parts, as the ABI imposed by <code>ifort</code> is incompatible with MSVC</p>
<p>A fully-optimized OpenBLAS that can be statically or dynamically linked to your
application can currently be built for the 64-bit architecture with the LLVM
compiler infrastructure. We're going to use [Miniforge3] the pre-configured
and more versatile alternative to <a href="https://docs.anaconda.com/miniconda/">Miniconda</a>
to grab all of the tools we need, since some of them are in an experimental
status. Before you begin, you'll need to have Microsoft Visual Studio 2015 or
newer installed.</p>
<ol>
<li>Install Miniforge for 64-bit Windows with the latest version of the installer Miniforge3-Windows-x86_64.exe
available on <a href="https://github.com/conda-forge/miniforge/releases/">github.com</a></li>
<li>Open the "Miniforge Command Prompt" now available in the Start Menu, or at <code>%USERPROFILE%\miniforge3\shell\condabin\conda-hook.ps1</code>.</li>
<li>In that command prompt window, use <code>cd</code> to change to the directory where you want to build OpenBLAS.</li>
<li>Now install all of the tools we need:
<div class="highlight"><pre><span></span><code>conda update -n base conda
conda install -y cmake flang_win-64 clangdev perl libflang ninja
</code></pre></div>
(if you want to build with OpenMP support, add <code>llvm-openmp</code> and <code>llvm-openmp-fortran</code>)</li>
<li>
<p>Still in the Anaconda Command Prompt window, activate the 64-bit MSVC environment with <code>vcvarsall x64</code>.
On Windows 11 with Visual Studio 2022, this would be done by invoking:</p>
<div class="highlight"><pre><span></span><code><span class="s2">&quot;c:\Program Files\Microsoft Visual Studio\2022\Community\vc\Auxiliary\Build\vcvars64.bat&quot;</span>
</code></pre></div>
<p>With VS2019, the command should be the same (except for the year number of course).
For other versions of MSVC, please check the Visual Studio documentation for
exactly how to invoke the <code>vcvars64.bat</code> script.</p>
<p>Confirm that the environment is active by typing <code>link</code>. This should return
a long list of possible options for the <code>link</code> command. If it just returns
<em>"command not found"</em> or similar, review and retype the call to <code>vcvars64.bat</code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>if you are working from a Visual Studio command prompt window instead
(so that you do not have to do the <code>vcvars</code> call), you need to invoke
<code>conda activate</code> so that <code>CONDA_PREFIX</code> etc. get set up correctly before
proceeding to step 6. Failing to do so will lead to link errors like
<code>libflangmain.lib</code> not getting found later in the build.</p>
</div>
</li>
<li>
<p>Now configure the project with CMake. Starting in the project directory, execute the following:
<div class="highlight"><pre><span></span><code>set &quot;LIB=%CONDA_PREFIX%\Library\lib;%LIB%&quot;
set &quot;CPATH=%CONDA_PREFIX%\Library\include;%CPATH%&quot;
mkdir build
cd build
cmake .. -G &quot;Ninja&quot; -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DCMAKE_MT=mt -DBUILD_WITHOUT_LAPACK=no -DNOFORTRAN=0 -DDYNAMIC_ARCH=ON -DCMAKE_BUILD_TYPE=Release
</code></pre></div></p>
<p>You may want to add further options in the <code>cmake</code> command here. For
instance, the default only produces a static <code>.lib</code> version of the library.
If you would rather have a DLL, add <code>-DBUILD_SHARED_LIBS=ON</code> above. Note that
this step only creates some command files and directories, the actual build
happens next.</p>
</li>
<li>
<p>Build the project:</p>
<p><div class="highlight"><pre><span></span><code>cmake --build . --config Release
</code></pre></div>
This step will create the OpenBLAS library in the <code>lib</code> directory, and
various build-time tests in the <code>test</code>, <code>ctest</code> and <code>openblas_utest</code>
directories. However it will not separate the header files you might need
for building your own programs from those used internally. To put all
relevant files in a more convenient arrangement, run the next step.</p>
</li>
<li>
<p>Install all relevant files created by the build:</p>
<p><div class="highlight"><pre><span></span><code>cmake --install . --prefix c:\opt -v
</code></pre></div>
This will copy all files that are needed for building and running your own
programs with OpenBLAS to the given location, creating appropriate
subdirectories for the individual kinds of files. In the case of <code>C:\opt</code> as
given above, this would be:</p>
<ul>
<li><code>C:\opt\include\openblas</code> for the header files, </li>
<li><code>C:\opt\bin</code> for the <code>libopenblas.dll</code> shared library,</li>
<li><code>C:\opt\lib</code> for the static library, and</li>
<li><code>C:\opt\share</code> holds various support files that enable other cmake-based
build scripts to find OpenBLAS automatically.</li>
</ul>
</li>
</ol>
<div class="admonition tip">
<p class="admonition-title">Change in complex types for Visual Studio 2017 and up</p>
<p>In newer Visual Studio versions, Microsoft has changed
<a href="https://docs.microsoft.com/en-us/cpp/c-runtime-library/complex-math-support?view=msvc-170#types-used-in-complex-math">how it handles complex types</a>.
Even when using a precompiled version of OpenBLAS, you might need to define
<code>LAPACK_COMPLEX_CUSTOM</code> in order to define complex types properly for MSVC.
For example, some variant of the following might help:</p>
<div class="highlight"><pre><span></span><code><span class="cp">#if defined(_MSC_VER)</span>
<span class="w"> </span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;complex.h&gt;</span>
<span class="w"> </span><span class="cp">#define LAPACK_COMPLEX_CUSTOM</span>
<span class="w"> </span><span class="cp">#define lapack_complex_float _Fcomplex</span>
<span class="w"> </span><span class="cp">#define lapack_complex_double _Dcomplex</span>
<span class="cp">#endif</span>
</code></pre></div>
<p>For reference, see
<a href="https://github.com/OpenMathLib/OpenBLAS/issues/3661">openblas#3661</a>,
<a href="https://github.com/Reference-LAPACK/lapack/issues/683">lapack#683</a>, and
<a href="https://stackoverflow.com/questions/47520244/using-openblas-lapacke-in-visual-studio">this Stack Overflow question</a>.</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Building 32-bit binaries with MSVC</p>
<p>This method may produce binaries which demonstrate significantly lower
performance than those built with the other methods. The Visual Studio
compiler does not support the dialect of assembly used in the cpu-specific
optimized files, so only the "generic" <code>TARGET</code> which is written in pure C
will get built. For the same reason it is not possible (and not necessary)
to use <code>-DDYNAMIC_ARCH=ON</code> in a Visual Studio build. You may consider
building for the 32-bit architecture using the GNU (MinGW) ABI instead.</p>
</div>
<h5 id="cmake-visual-studio-integration">CMake &amp; Visual Studio integration</h5>
<p>To generate Visual Studio solution files, ensure CMake is installed and then run:
<div class="highlight"><pre><span></span><code># Do this from Powershell so cmake can find visual studio
cmake -G &quot;Visual Studio 14 Win64&quot; -DCMAKE_BUILD_TYPE=Release .
</code></pre></div></p>
<p>To then build OpenBLAS using those solution files from within Visual Studio, we
also need Perl. Please install it and ensure it's on the <code>PATH</code> (see, e.g.,
<a href="http://stackoverflow.com/questions/3051049/active-perl-installation-on-windows-operating-system">this Stack Overflow question for how</a>).</p>
<p>If you build from within Visual Studio, the dependencies may not be
automatically configured: if you try to build <code>libopenblas</code> directly, it may
fail with a message saying that some <code>.obj</code> files aren't found. If this
happens, you can work around the problem by building the projects that
<code>libopenblas</code> depends on before building <code>libopenblas</code> itself.</p>
<h6 id="build-openblas-for-universal-windows-platform">Build OpenBLAS for Universal Windows Platform</h6>
<p>OpenBLAS can be built targeting <a href="https://en.wikipedia.org/wiki/Universal_Windows_Platform">Universal Windows Platform</a>
(UWP) like this:</p>
<ol>
<li>Follow the steps above to build the Visual Studio solution files for
Windows. This builds the helper executables which are required when building
the OpenBLAS Visual Studio solution files for UWP in step 2.</li>
<li>
<p>Remove the generated <code>CMakeCache.txt</code> and the <code>CMakeFiles</code> directory from
the OpenBLAS source directory, then re-run CMake with the following options:</p>
<p><div class="highlight"><pre><span></span><code># do this to build UWP compatible solution files
cmake -G &quot;Visual Studio 14 Win64&quot; -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=&quot;10.0&quot; -DCMAKE_SYSTEM_PROCESSOR=AMD64 -DVS_WINRT_COMPONENT=TRUE -DCMAKE_BUILD_TYPE=Release .
</code></pre></div>
3. Now build the solution with Visual Studio.</p>
</li>
</ol>
<h4 id="mingw-gnu-abi">MinGW &amp; GNU ABI</h4>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The resulting library from building with MinGW as described below can be
used in Visual Studio, but it can only be linked dynamically. This
configuration has not been thoroughly tested and should be considered
experimental.</p>
</div>
<p>To build OpenBLAS on Windows with MinGW:</p>
<ol>
<li>Install the MinGW (GCC) compiler suite, either the 32-bit
[MinGW]((http://www.mingw.org/) or the 64-bit
<a href="http://mingw-w64.sourceforge.net/">MinGW-w64</a> toolchain. Be sure to install
its <code>gfortran</code> package as well (unless you really want to build the BLAS part
of OpenBLAS only) and check that <code>gcc</code> and <code>gfortran</code> are the same version.
In addition, please install MSYS2 with MinGW.</li>
<li>Build OpenBLAS in the MSYS2 shell. Usually, you can just type <code>make</code>.
OpenBLAS will detect the compiler and CPU automatically. </li>
<li>After the build is complete, OpenBLAS will generate the static library
<code>libopenblas.a</code> and the shared library <code>libopenblas.dll</code> in the folder. You
can type <code>make PREFIX=/your/installation/path install</code> to install the
library to a certain location.</li>
</ol>
<p>Note that OpenBLAS will generate the import library <code>libopenblas.dll.a</code> for
<code>libopenblas.dll</code> by default.</p>
<p>If you want to generate Windows-native PDB files from a MinGW build, you can
use the <a href="https://github.com/rainers/cv2pdb">cv2pdb</a> tool to do so.</p>
<p>To then use the built OpenBLAS shared library in Visual Studio:</p>
<ol>
<li>Copy the import library (<code>OPENBLAS_TOP_DIR/libopenblas.dll.a</code>) and the
shared library (<code>libopenblas.dll</code>) into the same folder (this must be the
folder of your project that is going to use the BLAS library. You may need
to add <code>libopenblas.dll.a</code> to the linker input list: <code>properties-&gt;Linker-&gt;Input</code>).</li>
<li>Please follow the Visual Studio documentation about using third-party .dll
libraries, and make sure to link against a library for the correct
architecture.<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></li>
<li>If you need CBLAS, you should include <code>cblas.h</code> in
<code>/your/installation/path/include</code> in Visual Studio. Please see
<a href="http://github.com/OpenMathLib/OpenBLAS/issues/95">openblas#95</a> for more details.</li>
</ol>
<div class="admonition info">
<p class="admonition-title">Limitations of using the MinGW build within Visual Studio</p>
<ul>
<li>Both static and dynamic linking are supported with MinGW. With Visual
Studio, however, only dynamic linking is supported and so you should use
the import library.</li>
<li>Debugging from Visual Studio does not work because MinGW and Visual
Studio have incompatible formats for debug information (PDB vs.
DWARF/STABS). You should either debug with GDB on the command line or
with a visual frontend, for instance <a href="http://www.eclipse.org/cdt/">Eclipse</a> or
<a href="http://qt.nokia.com/products/developer-tools/">Qt Creator</a>.</li>
</ul>
</div>
<h3 id="windows-on-arm">Windows on Arm</h3>
<p>If you want to use a regular x64 Windows build of OpenBLAS with x64 software in the Prism emulator, be sure to use the latest version of Prism, and to check the box
to "Disable floating point optimization" in the Emulation settings. (Right-click on the executable to open "Properties", then on the "Compatibility" tab click on
"Change emulation settings").</p>
<p>A fully functional native OpenBLAS for WoA that can be built as both a static and dynamic library using LLVM toolchain and Visual Studio 2022. Before starting to build, make sure that you have installed Visual Studio 2022 on your ARM device, including the "Desktop Development with C++" component (that contains the cmake tool).
(Note that you can use the free "Visual Studio 2022 Community Edition" for this task. In principle it would be possible to build with VisualStudio alone, but using
the LLVM toolchain enables native compilation of the Fortran sources of LAPACK and of all the optimized assembly files, which VisualStudio cannot handle on its own)</p>
<ol>
<li>
<p>Clone OpenBLAS to your local machine and checkout to latest release of
OpenBLAS (unless you want to build the latest development snapshot - here we
are using the 0.3.28 release as the example, of course this exact version
may be outdated by the time you read this)</p>
<div class="highlight"><pre><span></span><code>git clone https://github.com/OpenMathLib/OpenBLAS.git
cd OpenBLAS
git checkout v0.3.28
</code></pre></div>
</li>
<li>
<p>Install Latest LLVM toolchain for WoA:</p>
<p>Download the Latest LLVM toolchain for WoA from <a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-19.1.5">the Release
page</a>. At
the time of writing, this is version 19.1.5 - be sure to select the
latest release for which you can find a precompiled package whose name ends
in "-woa64.exe" (precompiled packages usually lag a week or two behind their
corresponding source release). Make sure to enable the option
<em>“Add LLVM to the system PATH for all the users”</em>.</p>
<p>Note: Make sure that the path of LLVM toolchain is at the top of Environment
Variables section to avoid conflicts between the set of compilers available
in the system path</p>
</li>
<li>
<p>Launch the Native Command Prompt for Windows ARM64:</p>
<p>From the start menu search for <em>"ARM64 Native Tools Command Prompt for Visual
Studio 2022"</em>. Alternatively open command prompt, run the following command to
activate the environment:</p>
<div class="highlight"><pre><span></span><code>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsarm64.bat
</code></pre></div>
</li>
<li>
<p>Navigate to the OpenBLAS source code directory and start building OpenBLAS
by invoking Ninja:</p>
<div class="highlight"><pre><span></span><code>cd OpenBLAS
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DTARGET=ARMV8 -DBINARY=64 -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang-new
ninja -j16
</code></pre></div>
<p>Note: You might want to include additional options in the cmake command
here. For example, the default configuration only generates a
<code>static.lib</code> version of the library. If you prefer a DLL, you can add
<code>-DBUILD_SHARED_LIBS=ON</code>.</p>
<p>Note that it is also possible to use the same setup to build OpenBLAS
with Make, if you prefer Makefiles over the CMake build for some
reason:</p>
<div class="highlight"><pre><span></span><code>$ make CC=clang-cl FC=flang-new AR=&quot;llvm-ar&quot; TARGET=ARMV8 ARCH=arm64 RANLIB=&quot;llvm-ranlib&quot; MAKE=make
</code></pre></div>
</li>
</ol>
<h4 id="generating-an-import-library">Generating an import library</h4>
<p>Microsoft Windows has this thing called "import libraries". You need it for
MSVC; you don't need it for MinGW because the <code>ld</code> linker is smart enough -
however, you may still want it for some reason, so we'll describe the process
for both MSVC and MinGW.</p>
<p>Import libraries are compiled from a list of what symbols to use, which are
contained in a <code>.def</code> file. A <code>.def</code> file should be already be present in the
<code>exports</code> directory under the top-level OpenBLAS directory after you've run a build.
In your shell, move to this directory: <code>cd exports</code>.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="4:2"><input checked="checked" id="__tabbed_4_1" name="__tabbed_4" type="radio" /><input id="__tabbed_4_2" name="__tabbed_4" type="radio" /><div class="tabbed-labels"><label for="__tabbed_4_1">MSVC</label><label for="__tabbed_4_2">MinGW</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<p>Unlike MinGW, MSVC absolutely requires an import library. Now the C ABI of
MSVC and MinGW are actually identical, so linking is actually okay (any
incompatibility in the C ABI would be a bug).</p>
<p>The import libraries of MSVC have the suffix <code>.lib</code>. They are generated
from a <code>.def</code> file using MSVC's <code>lib.exe</code>.</p>
</div>
<div class="tabbed-block">
<p>MinGW import libraries have the suffix <code>.a</code>, just like static libraries.
Our goal is to produce the file <code>libopenblas.dll.a</code>.</p>
<p>You need to first insert a line <code>LIBRARY libopenblas.dll</code> in <code>libopenblas.def</code>:
<div class="highlight"><pre><span></span><code>cat &lt;(echo &quot;LIBRARY libopenblas.dll&quot;) libopenblas.def &gt; libopenblas.def.1
mv libopenblas.def.1 libopenblas.def
</code></pre></div></p>
<p>Now the <code>.def</code> file probably looks like:
<div class="highlight"><pre><span></span><code>LIBRARY libopenblas.dll
EXPORTS
caxpy=caxpy_ @1
caxpy_=caxpy_ @2
...
</code></pre></div>
Then, generate the import library: <code>dlltool -d libopenblas.def -l libopenblas.dll.a</code></p>
<p><em>Again, there is basically <strong>no point</strong> in making an import library for use in MinGW. It actually slows down linking.</em></p>
</div>
</div>
</div>
<h3 id="android">Android</h3>
<p>To build OpenBLAS for Android, you will need the following tools installed on your machine:</p>
<ul>
<li><a href="https://developer.android.com/ndk/">The Android NDK</a></li>
<li>Clang compiler on the build machine</li>
</ul>
<p>The next two sections below describe how to build with Clang for ARMV7 and
ARMV8 targets, respectively. The same basic principles as described below for
ARMV8 should also apply to building an x86 or x86-64 version (substitute
something like <code>NEHALEM</code> for the target instead of <code>ARMV8</code>, and replace all the
<code>aarch64</code> in the toolchain paths with <code>x86</code> or <code>x96_64</code> as appropriate).</p>
<div class="admonition info">
<p class="admonition-title">Historic note</p>
<p>Since NDK version 19, the default toolchain is provided as a standalone
toolchain, so building one yourself following
<a href="http://developer.android.com/ndk/guides/standalone_toolchain.html">building a standalone toolchain</a>
should no longer be necessary.</p>
</div>
<h4 id="building-for-armv7">Building for ARMV7</h4>
<div class="highlight"><pre><span></span><code><span class="c1"># Set path to ndk-bundle</span>
<span class="nb">export</span><span class="w"> </span><span class="nv">NDK_BUNDLE_DIR</span><span class="o">=</span>/path/to/ndk-bundle
<span class="c1"># Set the PATH to contain paths to clang and arm-linux-androideabi-* utilities</span>
<span class="nb">export</span><span class="w"> </span><span class="nv">PATH</span><span class="o">=</span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span>/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:<span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span>/toolchains/llvm/prebuilt/linux-x86_64/bin:<span class="nv">$PATH</span>
<span class="c1"># Set LDFLAGS so that the linker finds the appropriate libgcc</span>
<span class="nb">export</span><span class="w"> </span><span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">&quot;-L</span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span><span class="s2">/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x&quot;</span>
<span class="c1"># Set the clang cross compile flags</span>
<span class="nb">export</span><span class="w"> </span><span class="nv">CLANG_FLAGS</span><span class="o">=</span><span class="s2">&quot;-target arm-linux-androideabi -marm -mfpu=vfp -mfloat-abi=softfp --sysroot </span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span><span class="s2">/platforms/android-23/arch-arm -gcc-toolchain </span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span><span class="s2">/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/&quot;</span>
<span class="c1">#OpenBLAS Compile</span>
make<span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>ARMV7<span class="w"> </span><span class="nv">ONLY_CBLAS</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">AR</span><span class="o">=</span>ar<span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;clang </span><span class="si">${</span><span class="nv">CLANG_FLAGS</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="nv">ARM_SOFTFP_ABI</span><span class="o">=</span><span class="m">1</span><span class="w"> </span>-j4
</code></pre></div>
<p>On macOS, it may also be necessary to give the complete path to the <code>ar</code>
utility in the make command above, like so:
<div class="highlight"><pre><span></span><code><span class="nv">AR</span><span class="o">=</span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span>/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc-ar
</code></pre></div>
otherwise you may get a linker error complaining like <code>malformed archive header
name at 8</code> when the native macOS <code>ar</code> command was invoked instead. Note that
with recent NDK versions, the AR tool may be named <code>llvm-ar</code> rather than what
is assumed above.</p>
<h4 id="building-for-armv8">Building for ARMV8</h4>
<p><div class="highlight"><pre><span></span><code><span class="c1"># Set path to ndk-bundle</span>
<span class="nb">export</span><span class="w"> </span><span class="nv">NDK_BUNDLE_DIR</span><span class="o">=</span>/path/to/ndk-bundle/
<span class="c1"># Export PATH to contain directories of clang and aarch64-linux-android-* utilities</span>
<span class="nb">export</span><span class="w"> </span><span class="nv">PATH</span><span class="o">=</span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span>/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/:<span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span>/toolchains/llvm/prebuilt/linux-x86_64/bin:<span class="nv">$PATH</span>
<span class="c1"># Setup LDFLAGS so that loader can find libgcc and pass -lm for sqrt</span>
<span class="nb">export</span><span class="w"> </span><span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">&quot;-L</span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span><span class="s2">/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x -lm&quot;</span>
<span class="c1"># Setup the clang cross compile options</span>
<span class="nb">export</span><span class="w"> </span><span class="nv">CLANG_FLAGS</span><span class="o">=</span><span class="s2">&quot;-target aarch64-linux-android --sysroot </span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span><span class="s2">/platforms/android-23/arch-arm64 -gcc-toolchain </span><span class="si">${</span><span class="nv">NDK_BUNDLE_DIR</span><span class="si">}</span><span class="s2">/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/&quot;</span>
<span class="c1"># Compile</span>
make<span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>ARMV8<span class="w"> </span><span class="nv">ONLY_CBLAS</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">AR</span><span class="o">=</span>ar<span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;clang </span><span class="si">${</span><span class="nv">CLANG_FLAGS</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span>-j4
</code></pre></div>
Note: using <code>TARGET=CORTEXA57</code> in place of <code>ARMV8</code> will pick up better
optimized routines. Implementations for the <code>CORTEXA57</code> target are compatible
with all other <code>ARMV8</code> targets.</p>
<p>Note: for NDK 23b and later, something as simple as:
<div class="highlight"><pre><span></span><code><span class="nb">export</span><span class="w"> </span><span class="nv">PATH</span><span class="o">=</span>/opt/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/:<span class="nv">$PATH</span>
make<span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="nv">CC</span><span class="o">=</span>/opt/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang<span class="w"> </span><span class="nv">ONLY_CBLAS</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>ARMV8<span class="w"> </span><span class="nv">RANLIB</span><span class="o">=</span><span class="nb">echo</span>
</code></pre></div>
appears to be sufficient on Linux. On OSX, setting AR to the ar provided in the
"bin" path of the NDK (probably <code>llvm-ar</code>) is also necessary.</p>
<p>If you prefer building with CMake, running
<div class="highlight"><pre><span></span><code>cmake<span class="w"> </span>-DANDROID_ABI<span class="o">=</span>arm64-v8a<span class="w"> </span>-DTARGET<span class="o">=</span>ARMV8<span class="w"> </span>-DCMAKE_TOOLCHAIN_FILE<span class="o">=</span>/opt/android-ndk-r27/build/cmake/android.toolchain.cmake<span class="w"> </span>-DNOFORTRAN<span class="o">=</span><span class="m">1</span><span class="w"> </span>-DANDROID_PLATFORM<span class="o">=</span>android-23<span class="w"> </span>..
cmake<span class="w"> </span>--build<span class="w"> </span>.
</code></pre></div>
in your build directory should work (be sure to adjust the toolchain_file argument according to where you installed the NDK, and the ANDROID_PLATFORM
according to the minimum version of Android you want to support. (If you leave out the ANDROID_PLATFORM parameter, the build will fail with an error
message about a missing declaration or missing header file complex.h)</p>
<details class="note">
<summary>Alternative build script for 3 architectures</summary>
<p>This script will build OpenBLAS for 3 architecture (<code>ARMV7</code>, <code>ARMV8</code>,
<code>X86</code>) and install them to <code>/opt/OpenBLAS/lib</code>. Of course you can also copy
only the section that is of interest to you - also notice that the <code>AR=</code>
line may need adapting to the name of the ar tool provided in your
<code>$TOOLCHAIN/bin</code> - for example <code>llvm-ar</code> in some recent NDK versions.
It was tested on macOS with NDK version 21.3.6528147.</p>
<p><div class="highlight"><pre><span></span><code><span class="nb">export</span><span class="w"> </span><span class="nv">NDK</span><span class="o">=</span>YOUR_PATH_TO_SDK/Android/sdk/ndk/21.3.6528147
<span class="nb">export</span><span class="w"> </span><span class="nv">TOOLCHAIN</span><span class="o">=</span><span class="nv">$NDK</span>/toolchains/llvm/prebuilt/darwin-x86_64
make<span class="w"> </span>clean
make<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>ARMV7<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">ONLY_CBLAS</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$TOOLCHAIN</span><span class="s2">&quot;</span>/bin/armv7a-linux-androideabi21-clang<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">AR</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$TOOLCHAIN</span><span class="s2">&quot;</span>/bin/arm-linux-androideabi-ar<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">ARM_SOFTFP_ABI</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-j4
sudo<span class="w"> </span>make<span class="w"> </span>install
make<span class="w"> </span>clean
make<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>CORTEXA57<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">ONLY_CBLAS</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="nv">$TOOLCHAIN</span>/bin/aarch64-linux-android21-clang<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">AR</span><span class="o">=</span><span class="nv">$TOOLCHAIN</span>/bin/aarch64-linux-android-ar<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="se">\</span>
-j4
sudo<span class="w"> </span>make<span class="w"> </span>install
make<span class="w"> </span>clean
make<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>ATOM<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">ONLY_CBLAS</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="se">\</span>
<span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$TOOLCHAIN</span><span class="s2">&quot;</span>/bin/i686-linux-android21-clang<span class="w"> </span><span class="se">\</span>
<span class="nv">AR</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$TOOLCHAIN</span><span class="s2">&quot;</span>/bin/i686-linux-android-ar<span class="w"> </span><span class="se">\</span>
<span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="se">\</span>
<span class="nv">ARM_SOFTFP_ABI</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="se">\</span>
-j4
sudo<span class="w"> </span>make<span class="w"> </span>install
<span class="c1">## This will build for x86_64 </span>
make<span class="w"> </span>clean
make<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>ATOM<span class="w"> </span><span class="nv">BINARY</span><span class="o">=</span><span class="m">64</span><span class="se">\</span>
<span class="nv">ONLY_CBLAS</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="se">\</span>
<span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$TOOLCHAIN</span><span class="s2">&quot;</span>/bin/x86_64-linux-android21-clang<span class="w"> </span><span class="se">\</span>
<span class="nv">AR</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$TOOLCHAIN</span><span class="s2">&quot;</span>/bin/x86_64-linux-android-ar<span class="w"> </span><span class="se">\</span>
<span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="se">\</span>
<span class="nv">ARM_SOFTFP_ABI</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="se">\</span>
-j4
sudo<span class="w"> </span>make<span class="w"> </span>install
</code></pre></div>
You can find full list of target architectures in <a href="https://github.com/OpenMathLib/OpenBLAS/blob/develop/TargetList.txt">TargetList.txt</a></p>
</details>
<h3 id="iphoneios">iPhone/iOS</h3>
<p>As few of the current developers use iOS, the following instructions are what
was found to work in our Azure CI setup, but as far as we know this builds a
fully working OpenBLAS for this platform.</p>
<p>Go to the directory where you unpacked OpenBLAS,and enter the following commands:
<div class="highlight"><pre><span></span><code><span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>xcrun<span class="w"> </span>--sdk<span class="w"> </span>iphoneos<span class="w"> </span>--find<span class="w"> </span>clang<span class="k">)</span><span class="s2">&quot;</span>
<span class="nv">SDKROOT</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>xcrun<span class="w"> </span>--sdk<span class="w"> </span>iphoneos<span class="w"> </span>--show-sdk-path<span class="k">)</span><span class="s2">&quot;</span>
make<span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>ARMV8<span class="w"> </span><span class="nv">DYNAMIC_ARCH</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">NUM_THREADS</span><span class="o">=</span><span class="m">32</span><span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>clang<span class="w"> </span><span class="nv">NOFORTRAN</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">CC</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">&quot;-O2 -Wno-macro-redefined -isysroot </span><span class="si">${</span><span class="nv">SDKROOT</span><span class="si">}</span><span class="s2"> -arch arm64 -miphoneos-version-min=10.0&quot;</span>
</code></pre></div>
Adjust <code>-miphoneos-version-min</code> as necessary for your installation. E.g., change the version number
to the minimum iOS version you want to target and execute this file to build the library.</p>
<h3 id="harmonyos">HarmonyOS</h3>
<p>For this target you will need the cross-compiler toolchain package by Huawei,
which contains solutions for both Windows and Linux. Only the Linux-based
toolchain has been tested so far, but the following instructions may apply
similarly to Windows:</p>
<p>Download <a href="https://repo.huaweicloud.com/harmonyos/os/4.1.1-Release/ohos-sdk-windows_linux-public.tar.gz">this HarmonyOS 4.1.1 SDK</a>,
or whatever newer version may be available in the future). Use <code>tar -xvf
ohos-sdk-windows_linux_public.tar.gz</code> to unpack it somewhere on your system.
This will create a folder named "ohos-sdk" with subfolders "linux" and
"windows". In the linux one you will find a ZIP archive named
<code>native-linux-x64-4.1.7.8-Release.zip</code> - you need to unzip this where you want
to install the cross-compiler, for example in <code>/opt/ohos-sdk</code>.</p>
<p>In the directory where you unpacked OpenBLAS, create a build directory for cmake, and change into it :
<div class="highlight"><pre><span></span><code>mkdir<span class="w"> </span>build
<span class="nb">cd</span><span class="w"> </span>build
</code></pre></div>
Use the version of <code>cmake</code> that came with the SDK, and specify the location of
its toolchain file as a cmake option. Also set the build target for OpenBLAS to
<code>ARMV8</code> and specify <code>NOFORTRAN=1</code> (at least as of version 4.1.1, the SDK
contains no Fortran compiler):
<div class="highlight"><pre><span></span><code>/opt/ohos-sdk/linux/native/build-tools/cmake/bin/cmake<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-DCMAKE_TOOLCHAIN_FILE<span class="o">=</span>/opt/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-DOHOS_ARCH<span class="o">=</span><span class="s2">&quot;arm64-v8a&quot;</span><span class="w"> </span>-DTARGET<span class="o">=</span>ARMV8<span class="w"> </span>-DNOFORTRAN<span class="o">=</span><span class="m">1</span><span class="w"> </span>..
</code></pre></div>
Additional other OpenBLAS build options like <code>USE_OPENMP=1</code> or <code>DYNAMIC_ARCH=1</code>
will probably work too. Finally do the build:
<div class="highlight"><pre><span></span><code>/opt/ohos-sdk/linux/native/build-tools/cmake/bin/cmake<span class="w"> </span>--build<span class="w"> </span>.
</code></pre></div></p>
<h3 id="mips">MIPS</h3>
<p>For MIPS targets you will need latest toolchains:</p>
<ul>
<li>P5600 - MTI GNU/Linux Toolchain</li>
<li>I6400, P6600 - IMG GNU/Linux Toolchain</li>
</ul>
<p>You can use following commandlines for builds:</p>
<div class="highlight"><pre><span></span><code><span class="nv">IMG_TOOLCHAIN_DIR</span><span class="o">={</span>full<span class="w"> </span>IMG<span class="w"> </span>GNU/Linux<span class="w"> </span>Toolchain<span class="w"> </span>path<span class="w"> </span>including<span class="w"> </span><span class="s2">&quot;bin&quot;</span><span class="w"> </span>directory<span class="w"> </span>--<span class="w"> </span><span class="k">for</span><span class="w"> </span>example,<span class="w"> </span>/opt/linux_toolchain/bin<span class="o">}</span>
<span class="nv">IMG_GCC_PREFIX</span><span class="o">=</span>mips-img-linux-gnu
<span class="nv">IMG_TOOLCHAIN</span><span class="o">=</span><span class="si">${</span><span class="nv">IMG_TOOLCHAIN_DIR</span><span class="si">}</span>/<span class="si">${</span><span class="nv">IMG_GCC_PREFIX</span><span class="si">}</span>
<span class="c1"># I6400 Build (n32):</span>
make<span class="w"> </span><span class="nv">BINARY</span><span class="o">=</span><span class="m">32</span><span class="w"> </span><span class="nv">BINARY32</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-gcc<span class="w"> </span><span class="nv">AR</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-ar<span class="w"> </span><span class="nv">FC</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$IMG_TOOLCHAIN</span><span class="s2">-gfortran -EL -mabi=n32&quot;</span><span class="w"> </span><span class="nv">RANLIB</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-ranlib<span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">&quot;-EL&quot;</span><span class="w"> </span><span class="nv">FFLAGS</span><span class="o">=</span><span class="nv">$CFLAGS</span><span class="w"> </span><span class="nv">LDFLAGS</span><span class="o">=</span><span class="nv">$CFLAGS</span><span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>I6400
<span class="c1"># I6400 Build (n64):</span>
make<span class="w"> </span><span class="nv">BINARY</span><span class="o">=</span><span class="m">64</span><span class="w"> </span><span class="nv">BINARY64</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-gcc<span class="w"> </span><span class="nv">AR</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-ar<span class="w"> </span><span class="nv">FC</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$IMG_TOOLCHAIN</span><span class="s2">-gfortran -EL&quot;</span><span class="w"> </span><span class="nv">RANLIB</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-ranlib<span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">&quot;-EL&quot;</span><span class="w"> </span><span class="nv">FFLAGS</span><span class="o">=</span><span class="nv">$CFLAGS</span><span class="w"> </span><span class="nv">LDFLAGS</span><span class="o">=</span><span class="nv">$CFLAGS</span><span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>I6400
<span class="c1"># P6600 Build (n32):</span>
make<span class="w"> </span><span class="nv">BINARY</span><span class="o">=</span><span class="m">32</span><span class="w"> </span><span class="nv">BINARY32</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-gcc<span class="w"> </span><span class="nv">AR</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-ar<span class="w"> </span><span class="nv">FC</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$IMG_TOOLCHAIN</span><span class="s2">-gfortran -EL -mabi=n32&quot;</span><span class="w"> </span><span class="nv">RANLIB</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-ranlib<span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">&quot;-EL&quot;</span><span class="w"> </span><span class="nv">FFLAGS</span><span class="o">=</span><span class="nv">$CFLAGS</span><span class="w"> </span><span class="nv">LDFLAGS</span><span class="o">=</span><span class="nv">$CFLAGS</span><span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>P6600
<span class="c1"># P6600 Build (n64):</span>
make<span class="w"> </span><span class="nv">BINARY</span><span class="o">=</span><span class="m">64</span><span class="w"> </span><span class="nv">BINARY64</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-gcc<span class="w"> </span><span class="nv">AR</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-ar<span class="w"> </span><span class="nv">FC</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$IMG_TOOLCHAIN</span><span class="s2">-gfortran -EL&quot;</span><span class="w"> </span><span class="nv">RANLIB</span><span class="o">=</span><span class="nv">$IMG_TOOLCHAIN</span>-ranlib<span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">&quot;-EL&quot;</span><span class="w"> </span><span class="nv">FFLAGS</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$CFLAGS</span><span class="s2">&quot;</span><span class="w"> </span><span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$CFLAGS</span><span class="s2">&quot;</span><span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>P6600
<span class="nv">MTI_TOOLCHAIN_DIR</span><span class="o">={</span>full<span class="w"> </span>MTI<span class="w"> </span>GNU/Linux<span class="w"> </span>Toolchain<span class="w"> </span>path<span class="w"> </span>including<span class="w"> </span><span class="s2">&quot;bin&quot;</span><span class="w"> </span>directory<span class="w"> </span>--<span class="w"> </span><span class="k">for</span><span class="w"> </span>example,<span class="w"> </span>/opt/linux_toolchain/bin<span class="o">}</span>
<span class="nv">MTI_GCC_PREFIX</span><span class="o">=</span>mips-mti-linux-gnu
<span class="nv">MTI_TOOLCHAIN</span><span class="o">=</span><span class="si">${</span><span class="nv">IMG_TOOLCHAIN_DIR</span><span class="si">}</span>/<span class="si">${</span><span class="nv">IMG_GCC_PREFIX</span><span class="si">}</span>
<span class="c1"># P5600 Build:</span>
make<span class="w"> </span><span class="nv">BINARY</span><span class="o">=</span><span class="m">32</span><span class="w"> </span><span class="nv">BINARY32</span><span class="o">=</span><span class="m">1</span><span class="w"> </span><span class="nv">CC</span><span class="o">=</span><span class="nv">$MTI_TOOLCHAIN</span>-gcc<span class="w"> </span><span class="nv">AR</span><span class="o">=</span><span class="nv">$MTI_TOOLCHAIN</span>-ar<span class="w"> </span><span class="nv">FC</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$MTI_TOOLCHAIN</span><span class="s2">-gfortran -EL&quot;</span><span class="w"> </span><span class="nv">RANLIB</span><span class="o">=</span><span class="nv">$MTI_TOOLCHAIN</span>-ranlib<span class="w"> </span><span class="nv">HOSTCC</span><span class="o">=</span>gcc<span class="w"> </span><span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">&quot;-EL&quot;</span><span class="w"> </span><span class="nv">FFLAGS</span><span class="o">=</span><span class="nv">$CFLAGS</span><span class="w"> </span><span class="nv">LDFLAGS</span><span class="o">=</span><span class="nv">$CFLAGS</span><span class="w"> </span><span class="nv">TARGET</span><span class="o">=</span>P5600
</code></pre></div>
<h3 id="freebsd_1">FreeBSD</h3>
<p>You will need to install the following tools from the FreeBSD ports tree:</p>
<ul>
<li>lang/gcc</li>
<li>lang/perl5.12</li>
<li>ftp/curl</li>
<li>devel/gmake</li>
<li>devel/patch</li>
</ul>
<p>To compile run the command:
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>gmake<span class="w"> </span><span class="nv">CC</span><span class="o">=</span>gcc<span class="w"> </span><span class="nv">FC</span><span class="o">=</span>gfortran
</code></pre></div></p>
<h3 id="cortex-m">Cortex-M</h3>
<p>Cortex-M is a widely used microcontroller that is present in a variety of
industrial and consumer electronics. A common variant of the Cortex-M is the
<code>STM32F4xx</code> series. Here, we will give instructions for building for that
series.</p>
<p>First, install the embedded Arm GCC compiler from the Arm website. Then, create
the following <code>toolchain.cmake</code> file:</p>
<div class="highlight"><pre><span></span><code><span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_SYSTEM_NAME</span><span class="w"> </span><span class="s">Generic</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_SYSTEM_PROCESSOR</span><span class="w"> </span><span class="s">arm</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_C_COMPILER</span><span class="w"> </span><span class="s2">&quot;arm-none-eabi-gcc.exe&quot;</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_CXX_COMPILER</span><span class="w"> </span><span class="s2">&quot;arm-none-eabi-g++.exe&quot;</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_EXE_LINKER_FLAGS</span><span class="w"> </span><span class="s2">&quot;--specs=nosys.specs&quot;</span><span class="w"> </span><span class="s">CACHE</span><span class="w"> </span><span class="s">INTERNAL</span><span class="w"> </span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_FIND_ROOT_PATH_MODE_PROGRAM</span><span class="w"> </span><span class="s">NEVER</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_FIND_ROOT_PATH_MODE_LIBRARY</span><span class="w"> </span><span class="s">ONLY</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_FIND_ROOT_PATH_MODE_INCLUDE</span><span class="w"> </span><span class="s">ONLY</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span><span class="s">CMAKE_FIND_ROOT_PATH_MODE_PACKAGE</span><span class="w"> </span><span class="s">ONLY</span><span class="p">)</span>
</code></pre></div>
<p>Then build OpenBLAS with:
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>cmake<span class="w"> </span>..<span class="w"> </span>-G<span class="w"> </span>Ninja<span class="w"> </span>-DCMAKE_C_COMPILER<span class="o">=</span>arm-none-eabi-gcc<span class="w"> </span>-DCMAKE_TOOLCHAIN_FILE:PATH<span class="o">=</span><span class="s2">&quot;toolchain.cmake&quot;</span><span class="w"> </span>-DNOFORTRAN<span class="o">=</span><span class="m">1</span><span class="w"> </span>-DTARGET<span class="o">=</span>ARMV5<span class="w"> </span>-DEMBEDDED<span class="o">=</span><span class="m">1</span>
</code></pre></div></p>
<p>In your embedded application, the following functions need to be provided for OpenBLAS to work correctly:
<div class="highlight"><pre><span></span><code><span class="kt">void</span><span class="w"> </span><span class="nf">free</span><span class="p">(</span><span class="kt">void</span><span class="o">*</span><span class="w"> </span><span class="n">ptr</span><span class="p">);</span>
<span class="kt">void</span><span class="o">*</span><span class="w"> </span><span class="nf">malloc</span><span class="p">(</span><span class="kt">size_t</span><span class="w"> </span><span class="n">size</span><span class="p">);</span>
</code></pre></div></p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you are developing for an embedded platform, it is your responsibility
to make sure that the device has sufficient memory for <code>malloc</code> calls.
<a href="https://github.com/embeddedartistry/libmemory">Libmemory</a>
provides one implementation of <code>malloc</code> for embedded platforms.</p>
</div>
<div class="footnote">
<hr />
<ol>
<li id="fn:1">
<p>If the OpenBLAS DLLs are not linked correctly, you may see an error like
<em>"The application was unable to start correctly (0xc000007b)"</em>, which typically
indicates a mismatch between 32-bit and 64-bit libraries.&#160;<a class="footnote-backref" href="#fnref:1" title="Jump back to footnote 1 in the text">&#8617;</a></p>
</li>
</ol>
</div>
<aside class="md-source-file">
<span class="md-source-file__fact">
<span class="md-icon" title="Last update">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg>
</span>
<span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date" title="May 1, 2026 05:18:25 UTC">May 1, 2026</span>
</span>
<span class="md-source-file__fact">
<span class="md-icon" title="Created">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14.47 15.08 11 13V7h1.5v5.25l3.08 1.83c-.41.28-.79.62-1.11 1m-1.39 4.84c-.36.05-.71.08-1.08.08-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8c0 .37-.03.72-.08 1.08.69.1 1.33.32 1.92.64.1-.56.16-1.13.16-1.72 0-5.5-4.5-10-10-10S2 6.5 2 12s4.47 10 10 10c.59 0 1.16-.06 1.72-.16-.32-.59-.54-1.23-.64-1.92M18 15v3h-3v2h3v3h2v-3h3v-2h-3v-3z"/></svg>
</span>
<span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date" title="August 4, 2023 07:21:01 UTC">August 4, 2023</span>
</span>
</aside>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
<div class="md-copyright__highlight">
Copyright &copy; 2012- OpenBLAS contributors
</div>
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
<div class="md-social">
<a href="https://github.com/OpenMathLib/OpenBLAS" target="_blank" rel="noopener" title="github.com" class="md-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M173.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M252.8 8C114.1 8 8 113.3 8 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C436.2 457.8 504 362.9 504 252 504 113.3 391.5 8 252.8 8M105.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg>
</a>
<a href="https://github.com/OpenMathLib/OpenBLAS/LICENSE" target="_blank" rel="noopener" title="github.com" class="md-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 10a3.04 3.04 0 0 1 3-3 3.04 3.04 0 0 1 3 3 3.04 3.04 0 0 1-3 3 3.04 3.04 0 0 1-3-3m3 9 4 1v-3.08A7.54 7.54 0 0 1 12 18a7.54 7.54 0 0 1-4-1.08V20m4-16a5.78 5.78 0 0 0-4.24 1.74A5.78 5.78 0 0 0 6 10a5.78 5.78 0 0 0 1.76 4.23A5.78 5.78 0 0 0 12 16a5.78 5.78 0 0 0 4.24-1.77A5.78 5.78 0 0 0 18 10a5.78 5.78 0 0 0-1.76-4.26A5.78 5.78 0 0 0 12 4m8 6a8 8 0 0 1-.57 2.8A7.8 7.8 0 0 1 18 15.28V23l-6-2-6 2v-7.72A7.9 7.9 0 0 1 4 10a7.68 7.68 0 0 1 2.33-5.64A7.73 7.73 0 0 1 12 2a7.73 7.73 0 0 1 5.67 2.36A7.68 7.68 0 0 1 20 10"/></svg>
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"annotate": null, "base": "..", "features": ["header.autohide"], "search": "../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script>
<script src="../assets/javascripts/bundle.79ae519e.min.js"></script>
</body>
</html>