Building FPM from source on Windows 10

I’m reading the instructions for the FPM package manager and was wondering what the procedure was to build from source directly from git? I have the most recent sources locally, but it isn’t clear from the shell script what I need to do to get this to compile on Windows using gfortran. Any advice?

1 Like

Building fpm from the git repository head is usually a two-step bootstrap process, since fpm is build with fpm itself. Therefore, to build fpm from the git source you first have to get a fpm version from somewhere.

There are several ways to get an initial fpm version:

  • download a statically linked Windows binary from the release page
  • download a single-source version from the release page and compile it with
    gfortran fpm-0.3.0.F90 -o fpm
  • if you using MSYS2 you can download a prepackaged version or build it yourself from here

After you have your first fpm version in the PATH you can enter the repository root and run

fpm install --profile release

On Windows it will install to %APPDATA%\local\bin\fpm.exe by default. Not sure if this is the best choice on Windows, but that’s the one I put in as default there. The install.sh automates this two-step procedure for Unix like systems, but it might just work with git bash or the MSYS2 toolchain.

3 Likes

Thanks. I read that section on github a number of times; I’m not sure why it didn’t click. There are a few common lisp compilers that use a similar bootstrap approach – ie. offer a reduced capability lisp kernel written in C, and use that to build the rest.

Perhaps adding a phrase “bootstrapping and/or building from git” to the instructions might help?

Update: @awvwgk I made some progress building from source but I still get stuck. Here is my current set up:

Compiler: GCC version 10.3.0 from TDM-GCC
Install PATH = $HOME\devtools\utilities\fortran

I can copy that single source version and compile it. After adding the install path to my windows PATH variable, if I run your fpm install command, I get “fpm.toml cannot be found”

Since I have the git sources, I tried to copy fpm.toml to the directory I compiled the bootstrap fpm source file in.

I make it a bit farther. A new directory “build” gets created with cache.toml and a dependencies directory, but then I get “cannot open ‘test/cli_test\cli_test.f90’: no such file or directory”

I wonder if I have the right version of fpm.toml.

1 Like

Hi @R_cubed. You can try this batch script

rem Put required tools in PATH (git, gfortran, curl)
set path=C:\Git\cmd;C:\Git\usr\bin;C:\MinGW-11.1.0-x64\bin;C:\WINDOWS\system32

git clone https://github.com/fortran-lang/fpm.git
cd fpm
mkdir _tmp
curl -LJ https://github.com/fortran-lang/fpm/releases/download/v0.3.0/fpm-0.3.0.F90 > _tmp\fpm.F90
gfortran -J _tmp _tmp\fpm.F90 -o _tmp\fpm
_tmp\fpm install --flag "-g -fbacktrace -O3"
echo fpm has been installed into %appdata%\local\bin 👍
3 Likes

That looks like it worked. FPM is in my path, and I was able to build and install the FPM sources. Running fpm test gave me a message “Passed: all 11 tests passed”

How do I connect my local FPM installation with this centralized repository?

Added: A link to setting up a development environment on Windows for those who might stumble upon this thread.

1 Like

I believe it doesn’t work yet? But that is our plan!

2 Likes

We fortran-lang community need to write the specification for fpm-registry and then implement it.

Relevant issues

and many others …

2 Likes

Thanks for the info.

Just so this idea doesn’t get lost or forgotten, it is worth considering to have the organization of the various libraries structured to match the taxonomies developed over the years. The NIST Guide to Available Mathematical Software (GAMS) as well as the Digital Library of Mathematical Functions (DLMF) were mentioned in this older thread.

Hopefully, that will make teaching the math along with the programming easier.

2 Likes