# Unable to install gfortan

**URL:** <https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565>\
**Category:** Help\
**Created:** [April 14, 2023, 7:31am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565 "2023-04-14T07:31:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 7:31am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/1 "2023-04-14T07:31:10Z")

</div>

I spent most of two days failing to get mingw-64 installed. I have removed the failed attempts and now have mingw-w64-v10.0.0 in the download file - not yet unpacked. Could someone please!! help me through the steps till and including compiling the test program at j:\x\New.f90?

---

<div class="post-metadata">

**Author:** ![Euler-37](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Euler-37](https://fortran-lang.discourse.group/u/Euler-37)\
**Post date:** [April 14, 2023, 8:01am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/2 "2023-04-14T08:01:07Z")

</div>

You can download [gcc-12.2.0-64.exe](http://www.equation.com/ftpdir/gcc/gcc-12.2.0-64.exe) from this website

> **[Fortran, C, C++ for Windows](http://www.equation.com/servlet/equation.cmd?fa=fortran)**
>
> Free C, C++ and Fortran for Windows

and read quick tutorial

[https://fortran-lang.org/en/learn/quickstart/hello\_world](https://fortran-lang.org/en/learn/quickstart/hello_world)

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 8:10am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/3 "2023-04-14T08:10:27Z")

</div>

Should I allow setup to take place here?  
C:\Users\pader\gcc

---

<div class="post-metadata">

**Author:** ![Euler-37](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Euler-37](https://fortran-lang.discourse.group/u/Euler-37)\
**Post date:** [April 14, 2023, 8:18am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/4 "2023-04-14T08:18:40Z")

</div>

Yes, or you can choose another path if you want.

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 8:25am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/5 "2023-04-14T08:25:13Z")

</div>

Okay done, what is the next step? if I do the check on your hello world it doesn’t recognise the commands

---

<div class="post-metadata">

**Author:** ![Euler-37](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Euler-37](https://fortran-lang.discourse.group/u/Euler-37)\
**Post date:** [April 14, 2023, 8:40am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/6 "2023-04-14T08:40:58Z")

</div>

You can use windows cmd/powershell to compile the file  
,or use vscode as you IDE

both of these are not easy for beginners,you can find some videos on Youtube ,just search [fortran vscode]

---

<div class="post-metadata">

**Author:** ![zoziha](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/zoziha/32/582_2.png) [@zoziha](https://fortran-lang.discourse.group/u/zoziha)\
**Post date:** [April 14, 2023, 8:45am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/7 "2023-04-14T08:45:25Z")

</div>

For Windows users who want to use gfortran, I definitely recommend [Windows-MSYS2](https://www.msys2.org/), it’s so complete and modern, including various unix tools, CMake, GCC, OpenBLAS, HDF5, Lua …

For writing Fortran, basically, you need a text editor, which could be VSCode, and a build tool, which could be CMake or Meson. A good `terminal` would be better, I like PowerShell+PSReadline+Starship.

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 8:46am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/8 "2023-04-14T08:46:30Z")

</div>

what should I enter in the dos textbox to do as you say?  
I have a test program in j:\x\trialOne.f9. I crashed my pc yesterday in all my vain attempts. I am taking no risks now.

---

<div class="post-metadata">

**Author:** ![Euler-37](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Euler-37](https://fortran-lang.discourse.group/u/Euler-37)\
**Post date:** [April 14, 2023, 8:49am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/9 "2023-04-14T08:49:27Z")

</div>

1. using `cd` command to file directory ,`cd j:\x`
2. compile it `gfortran trialOne.f90 -o a.exe`
3. run it `a.exe`

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 8:49am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/10 "2023-04-14T08:49:31Z")

</div>

I am dong what euler tells me to do

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 8:51am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/11 "2023-04-14T08:51:07Z")

</div>

gfortran is not recognised as a command  
I am in c:\users\pader

---

<div class="post-metadata">

**Author:** ![Euler-37](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Euler-37](https://fortran-lang.discourse.group/u/Euler-37)\
**Post date:** [April 14, 2023, 8:54am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/12 "2023-04-14T08:54:40Z")

</div>

maybe the last step,you reject it `Add to PATH`

you should add `your gcc install path` to windows environment variables

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 8:58am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/13 "2023-04-14T08:58:20Z")

</div>

how do I do that? I don’t want to crash my system like yesterday again.  
I am in c:\users\pader

---

<div class="post-metadata">

**Author:** ![zoziha](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/zoziha/32/582_2.png) [@zoziha](https://fortran-lang.discourse.group/u/zoziha)\
**Post date:** [April 14, 2023, 9:02am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/14 "2023-04-14T09:02:01Z")

</div>

[Setting up your OS — Fortran Programming Language (fortran-lang.org)](https://fortran-lang.org/en/learn/os_setup/index)

[Fortran-lang.org](http://Fortran-lang.org) has a tutorial on configuring your OS and compiler that might be helpful.

---

<div class="post-metadata">

**Author:** ![Euler-37](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Euler-37](https://fortran-lang.discourse.group/u/Euler-37)\
**Post date:** [April 14, 2023, 9:03am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/15 "2023-04-14T09:03:48Z")

</div>

google it

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 9:07am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/16 "2023-04-14T09:07:25Z")

</div>

To Euler

I am in c:\users\pader  
I have  
c:\users\pader\gcc\X86\_64-W64-mingw32  
You say I have a path missing, so what is next?

---

<div class="post-metadata">

**Author:** ![Euler-37](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Euler-37](https://fortran-lang.discourse.group/u/Euler-37)\
**Post date:** [April 14, 2023, 9:26am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/17 "2023-04-14T09:26:53Z")

</div>

add **`c:\users\pader\gcc\bin`** to system path variable

> **[How to Change the PATH Environment Variable on Windows: 14 Steps](https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows)**
>
> A simple guide to adding a directory to the Windows 10/11 path variable The PATH environment variable specifies in which directories the Windows command line looks for executable binaries. The process for changing it is not obvious, but...

 ![图片](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/1/16ae6f449014f76bb1c6933b0c6421b6b05d9ee6.jpeg)

**reopen cmd**

if successed you should see

```auto
c:\users\pader> gfortran
gfortran: fatal error: no input files
compilation terminated.

```

and then

1. `j:` change your path to `j`
2. `cd x` enter directory x using
3. `gfortran trialOne.f90 -o a.exe` compile it
4. `a.exe` run it

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [April 14, 2023, 9:54am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/18 "2023-04-14T09:54:16Z")

</div>

J:\>gfortran trialOne.f90 -o a.exe

‘gfortran’ is not recognized as an internal or external command, operable program or batch file.

J; is the directory where trialOne.f90 is located

**what should I do?**

I can get to: c:\users\pader\gcc\bin **What then?**

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [April 14, 2023, 11:42am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/19 "2023-04-14T11:42:13Z")

</div>

Please follow the last instructions by @Euler-37 about modifying the environment variable `PATH`.

But first, you need to understand that your operating system (Windows) has so-called _environment variables_ that contain useful information for it.

The `PATH` variable contains a list of directories, separated by “;”.

If you type the name of a command/program in your terminal, for example `gfortran`, Windows will try to find the program `gfortran` in each directory listed in its variable `PATH`, one after the other. If Windows does not find `gfortran` in any directory, it will print an error message like “command not found”. If `gfortran` is found in one of these directories, it will be executed.

If you don’t put the directory of the `gfortran` executable into `PATH`, you will be able to run `gfortran` only in its own directory, which is not practical… Generally, you want to be able to run `gfortran` from any directory where you are working. So a first step is to add its directory after a “;” at the end of the `PATH` variable (just append that directory, don’t delete the other directories).

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [April 14, 2023, 11:48am UTC](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565/20 "2023-04-14T11:48:59Z")

</div>

In addition to what @vmagnin wrote I will add that

`c:\somedir>echo %path%`

will display the current path, which needs to be changed, as described above, if it does not contain the directory where gfortran is installed.

[Next page](https://fortran-lang.discourse.group/t/unable-to-install-gfortan/5565.md?page=2)
