# How to install the fortran stdlib in MacOS by home-brew?

**URL:** <https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418>\
**Category:** Help\
**Created:** [September 25, 2025, 8:12am UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418 "2025-09-25T08:12:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiqsh](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shiqsh/32/6506_2.png) [@shiqsh](https://fortran-lang.discourse.group/u/shiqsh)\
**Post date:** [September 25, 2025, 8:12am UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/1 "2025-09-25T08:12:50Z")

</div>

Every time when I try to install the fortran stdlib in MacOS with

```auto
brew tap fortran-lang/stdlib
brew install fortran-lang/stdlib/stdlib

```

and it shows me with the error

```auto
Cloning into '/opt/homebrew/Library/Taps/fortran-lang/homebrew-stdlib'...
Username for 'https://github.com': shiqsh
Password for 'https://xxxx@github.com': 
remote: Repository not found.
fatal: repository 'https://github.com/fortran-lang/homebrew-stdlib/' not found
Error: Failure while executing; `git clone https://github.com/fortran-lang/homebrew-stdlib /opt/homebrew/Library/Taps/fortran-lang/homebrew-stdlib --origin=origin --template= --config core.fsmonitor=false` exited with 128.

```

So how to fix the error? and if there is a easy way to install the fortran-stdlib in MacOS?

Also while install the fortran-stdlib bty

```auto
brew install fortran-stdlib

```

and the mod file are in the

```auto
/opt/homebrew/Cellar/fortran-stdlib/0.7.0/include/fortran_stdlib/GNU-14.2.0

```

with the compile command

```auto
gfortran -I/opt/homebrew/Cellar/fortran-stdlib/0.7.0/include/fortran_stdlib/GNU-14.2.0 test_stdlib.f90 -o test_stdlib
./test_stdlib

```

there is still a error with

```auto
Fatal Error: Cannot open module file 'fortran_stdlib.mod' for reading at (1): No such file or directory

```

So, what is the problem and how to fix it?

---

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [September 25, 2025, 8:24am UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/2 "2025-09-25T08:24:55Z")

</div>

Unless there is some magic I’m not aware of in the MacOS world (not a mac user), `stdlib` is not a package installable through any OS package manager. It is a source-code based library that you have to download, build and install, for instance using CMake or FPM. The instructions are here [GitHub - fortran-lang/stdlib: Fortran Standard Library](https://github.com/fortran-lang/stdlib?tab=readme-ov-file#getting-started)

---

<div class="post-metadata">

**Author:** ![fxm](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/fxm/32/5726_2.png) [@fxm](https://fortran-lang.discourse.group/u/fxm)\
**Post date:** [September 25, 2025, 8:53am UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/3 "2025-09-25T08:53:16Z")

</div>

Hi @shiqsh,

As far as I’m aware, `stdlib` isn’t a package installable through brew any more than it is through aptitude, pacman, etc.. If you are using the [Fortran Package Manager](https://fpm.fortran-lang.org/) for your project, the easiest way is to simply include the stdlib metapackage by adding to following to your project’s `toml` file:

```auto
[dependencies]
stdlib = "*"

```

Simple and hassle-free. More info and alternatives are in the README in stdlib’s repository that @hkvzjal pointed to.

---

<div class="post-metadata">

**Author:** ![suprit05](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@suprit05](https://fortran-lang.discourse.group/u/suprit05)\
**Post date:** [September 25, 2025, 8:37pm UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/4 "2025-09-25T20:37:12Z")

</div>

> [@shiqsh](#):
>
> there is still a error with
> 
> ```auto
> Fatal Error: Cannot open module file 'fortran_stdlib.mod' for reading at (1): No such file or directory
> 
> ```

Hello! `stdlib` is a collection of modules and there is no such module as `fortran_stdlib` which you seem to be using in your in source file `test_stdlib.f90`

Instead a minimal testing source file could be this

```f90
program demo
    use stdlib_ascii, only: is_lower
    implicit none 
    
    print *, is_lower('a')
end program demo

```

Compile it with the following command (Don’t forget to link with the static library as below!)

```bash
gfortran stdlib_test.f90 -I/opt/homebrew/Cellar/fortran-stdlib/0.7.0/include/fortran_stdlib/GNU-14.2.0/ -L/opt/homebrew/Cellar/fortran-stdlib/0.7.0/lib/ -lfortran_stdlib

```

This should produce an executable with the desired output.

of course the compile command can turn real messy real fast, you could try to shorten it by making use of `pkgconfig`, the pkgconfig file for `stdlib` is located at `/opt/homebrew/Cellar/fortran-stdlib/0.7.0/lib/pkgconfig/fortran_stdlib.pc`

---

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [September 26, 2025, 11:12am UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/5 "2025-09-26T11:12:40Z")

</div>

> [@fxm](#):
>
> As far as I’m aware, `stdlib` isn’t a package installable through brew any more than it is through aptitude, pacman, etc.

If one does a google search on “homebrew fortran-stdlib”, then the AI Overview does indeed indicate that the command “brew install fortran-stdlib” is supported within the homebrew package manager.

> [@suprit05](#):
>
> Hello! `stdlib` is a collection of modules and there is no such module as `fortran_stdlib` […]

I think this is the problem. Namely, what is the `USE` statement in your fortran code? That is what tells the compiler which module file to search for. Module files are created by the fortran compiler during the build of stdlib, and to use them afterwards, both the object file (`somename.o`) and the module file (`modulename.mod`) are used. I don’t know the details beyond that for stdlib, but it is likely that the `*.o` files are moved into an archive library so that only that one library needs to be searched during the load step (either `ld`, or by the fortran compiler itself). However, the `*.mod` files must usually be available themselves, not from a library of merged files.

> [@suprit05](#):
>
> `use stdlib_ascii, only: is_lower`

Note the module name that is referenced in the USE statement.

Right now, and for the foreseeable future, each fortran compiler has its own `*.mod` file format, so individual compilers need to create their own files, and one compiler cannot access another compiler’s `*.mod` files.

I am not a fortran-stdlib user, so the above comments are just based on what the google search says.

---

<div class="post-metadata">

**Author:** ![shiqsh](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shiqsh/32/6506_2.png) [@shiqsh](https://fortran-lang.discourse.group/u/shiqsh)\
**Post date:** [September 30, 2025, 7:56am UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/7 "2025-09-30T07:56:31Z")

</div>

many thanks. But I have another question that if I use FPM and add the code in my toml file, how can I use the fpm with openmp？ also add something in the toml file?

---

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [September 30, 2025, 10:08am UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/8 "2025-09-30T10:08:52Z")

</div>

You could use the meta-package option of FPM adding this to your .toml [Computing PI with OpenMP — Fortran Package Manager](https://fpm.fortran-lang.org//how-to/compute-pi-openmp.html)

```auto
[dependencies]
openmp = "*"

```

Note that OpenMP is provided by the compiler, not FPM. This will manage the basic compiler flags passed to the compiler.

For full control, pass flags instead with

gfortran

```auto
fpm run --flag "-O3 -fopenmp"

```

ifort/ifx

```auto
fpm run --flag "-O3 -qopenmp"

```

You can store your flags in a response (fpm.rsp) file to easily run several tests with different compilers/flags combinations.

---

<div class="post-metadata">

**Author:** ![shiqsh](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shiqsh/32/6506_2.png) [@shiqsh](https://fortran-lang.discourse.group/u/shiqsh)\
**Post date:** [September 30, 2025, 10:30am UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/9 "2025-09-30T10:30:41Z")

</div>

that’s it. much much appreciated.

---

<div class="post-metadata">

**Author:** ![msz59](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@msz59](https://fortran-lang.discourse.group/u/msz59)\
**Post date:** [October 1, 2025, 6:13pm UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/10 "2025-10-01T18:13:14Z")

</div>

> [@suprit05](#):
>
> of course the compile command can turn real messy real fast, you could try to shorten it by making use of `pkgconfig`, the pkgconfig file for `stdlib` is located at `/opt/homebrew/Cellar/fortran-stdlib/0.7.0/lib/pkgconfig/fortran_stdlib.pc`

All homebrew-installed pkg-config files (\*.pc) get symlinked (at least in Linux, MacOS) to `$HOMEBREW_PREFIX/lib/pkgconfig/` directory which makes them simple to add to `PKG_CONFIG_PATH` variable. Also, using `$HOMEBREW_PREFIX` instead of a hardcoded path like `/opt/homebrew` make the configuration, compiler options _etc._ as OS-independent as possible.

---

<div class="post-metadata">

**Author:** ![msz59](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@msz59](https://fortran-lang.discourse.group/u/msz59)\
**Post date:** [October 1, 2025, 6:42pm UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/11 "2025-10-01T18:42:22Z")

</div>

> [@fxm](#):
>
> If you are using the [Fortran Package Manager](https://fpm.fortran-lang.org/) for your project, the easiest way is to simply include the stdlib metapackage by adding to following to your project’s `toml` file:
> 
> ```auto
> [dependencies]
> stdlib = "*"
> 
> ```
> 
> Simple and hassle-free. More info and alternatives are in the README in stdlib’s repository that @hkvzjal pointed to.

AFAIU (correct me if I am wrong, I’d love to be!), the above trick makes `fpm` download `stdlib` sources for every project that uses the library. I could not find a recipe for using a system/user installed `stdlib` in FPM projects (as it shows for CMake/Makefile projects), unless `stdlib = "*"` automagically finds the system-wide or user installation.

---

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [October 1, 2025, 7:00pm UTC](https://fortran-lang.discourse.group/t/how-to-install-the-fortran-stdlib-in-macos-by-home-brew/10418/12 "2025-10-01T19:00:35Z")

</div>

You are not wrong, and that’s one of the things that I personally don’t like about the current way fpm handles dependencies. I preferer to get the required packages locally and then declare the dependencies with the path option.

> [@Fortran stdlib: sufficient for scientific programming?](https://fortran-lang.discourse.group/t/fortran-stdlib-sufficient-for-scientific-programming/8905/22):
>
> In the fpm.toml, add stdlib as a dependency using your locally downloaded version [fpm local dependencies](https://fpm.fortran-lang.org/spec/manifest.html?highlight=local#local-dependencies):
> 
> ```auto
> [dependencies]
> stdlib = { path = "../stdlib" }
> 
> ```

Now, FPM does enable you to “install” in the proper term [Manifest reference — Fortran Package Manager](https://fpm.fortran-lang.org/spec/manifest.html?highlight=install#installation-configuration) which would then enable you to link against your pre-compiled static library.

Another option, which I haven’t tested, is creating a local registry [Settings — Fortran Package Manager](https://fpm.fortran-lang.org/registry/settings.html#local-registry)
