# I have a problem with LFortran installation

**URL:** <https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440>\
**Category:** LFortran\
**Created:** [December 22, 2021, 6:48pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440 "2021-12-22T18:48:51Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [January 18, 2022, 5:06pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/26 "2022-01-18T17:06:15Z")

</div>

> [@Reza](#):
>
> specifically for 2/3 in line 2.

Yes, that is correct, in Fortran 2/3 is an integer division, so the result is 0.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [January 18, 2022, 5:16pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/27 "2022-01-18T17:16:53Z")

</div>

> [@Reza](#):
>
> now the problem is solved and it works very well.

Awesome, I am glad it works now. Yes, the Python issues that you discovered are precisely the reason we switched from Python to C++ as the implementation of LFortran. The issues with Python can be summarized as follows:

- The various Python libraries that Jupyter depends on are not always compatible
- You only find out at runtime, and typically get some obscure error message such as the ones above
- There are multiple mechanisms how to install Python packages, and none has became the clear winner yet, although Conda is pretty close; And if you mix and match these mechanisms, things will fail, as you saw above

C++ is unfortunately also missing a package manager (there are several, and none is a clear winner), but in my experience if it compiles, it almost always works. So at least we don’t have to deal with these runtime issues in C++ (or Fortran). The issue still remains how to make it easy to compile. For now Conda is a nice solution as it is already compiled there, but if you want to build from source, it’s not easy. For Fortran I think fpm will fix this. C++ currently doesn’t have a solution like that, but if we can improve `fpm` to also work for C++, which technically I am pretty sure we can, then I’d be happy to use it for LFortran also.

---

<div class="post-metadata">

**Author:** ![Reza](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reza](https://fortran-lang.discourse.group/u/Reza)\
**Post date:** [January 18, 2022, 5:50pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/28 "2022-01-18T17:50:21Z")

</div>

Thank you very much for your support and help. I’ve been using Fortran as the core of the numerical models that I’m working on for a few years, and I enjoy it. Sadly, I do not have the knowledge to contribute to the improvement and development of LFORTRAN, but if there were anything I could do, I would enjoy it.  
I believe that LFORTRAN is a potent language. I did a simple test with a simple loop, both in LFORTRAN and Python, and LFORTRAN showed its speed very well. I am not sure if it is possible, but if users can easily add and use packages just like in Python, I think that would be ideal.

---

<div class="post-metadata">

**Author:** ![Harper](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@Harper](https://fortran-lang.discourse.group/u/Harper)\
**Post date:** [March 29, 2024, 8:02am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/29 "2024-03-29T08:02:09Z")

</div>

I am familiar with Fortran but not with systems programming or conda. Wanting to try another compiler I tried to follow the Lfortran website’s instructions but was stymied. The lines beginning with 3 or 4 digit numbers are from my history file, showing what I did in my Ubuntu 22.04 system, followed by the error messages and what I tried next. What should I do now?

```auto
  990 29/03 20:11 conda create -n lf
  991 29/03 20:11 locate miniconda
  992 29/03 20:14 wget --no-check-certificate https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
  993 29/03 20:14 bash miniconda.sh -b -p $HOME/conda_root
  994 29/03 20:15 export PATH="$HOME/conda_root/bin:$PATH"
  995 29/03 20:15 conda create -n lf -c conda-forge llvmdev=11.0.1 bison=3.4 re2c python cmake make toml
  996 29/03 20:16 conda activate lf
  997 29/03 20:16 conda init
  998 29/03 20:16 conda activate lf
  999 29/03 20:17 h
 1000 29/03 20:17 conda activate lf
 1001 29/03 20:17 git clone https://github.com/lfortran/lfortran.git
 1002 29/03 20:18 cd lfortran
 1003 29/03 20:18 ./build0.sh
 1004 29/03 20:19 cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_LLVM=yes -DCMAKE_INSTALL_PREFIX=`pwd`/inst .
 1005 29/03 20:19 h
 1006 29/03 20:20 cmake -DWITH_LLVM=yes -DCMAKE_INSTALL_PREFIX=`pwd`/inst .
 1007 29/03 20:20 make -j8

1004 gave this error message

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - broken
Make Error at /home/john/conda_root/envs/lf/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/home/john/lfortran/CMakeFiles/CMakeScratch/TryCompile-B1lpDx'
    
    Run Build Command(s): /home/john/conda_root/envs/lf/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_fa862/fast
    /usr/bin/gmake -f CMakeFiles/cmTC_fa862.dir/build.make CMakeFiles/cmTC_fa862.dir/build
    gmake[1]: Entering directory '/home/john/lfortran/CMakeFiles/CMakeScratch/TryCompile-B1lpDx'
    Building C object CMakeFiles/cmTC_fa862.dir/testCCompiler.c.o
    /usr/bin/cc -o CMakeFiles/cmTC_fa862.dir/testCCompiler.c.o -c /home/john/lfortran/CMakeFiles/CMakeScratch/TryCompile-B1lpDx/testCCompiler.c
    cc: fatal error: cannot execute ‘cc1’: execvp: No such file or directory
    compilation terminated.
    gmake[1]: *** [CMakeFiles/cmTC_fa862.dir/build.make:78: CMakeFiles/cmTC_fa862.dir/testCCompiler.c.o] Error 1
    gmake[1]: Leaving directory '/home/john/lfortran/CMakeFiles/CMakeScratch/TryCompile-B1lpDx'
    gmake: *** [Makefile:127: cmTC_fa862/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:17 (project)

-- Configuring incomplete, errors occurred!

On trying to see why I got
-- The C compiler identification is unknown
I looked for it and got this:

(lf) john@johns-laptop:/usr/bin$ ls -ltra cc
lrwxrwxrwx 1 root root 20 Dec 25 2018 cc -> /etc/alternatives/cc
(lf) john@johns-laptop:/usr/bin$ ls -ltra /etc/alternatives/cc
lrwxrwxrwx 1 root root 12 Dec 25 2018 /etc/alternatives/cc -> /usr/bin/gcc
(lf) john@johns-laptop:/usr/bin$ ls -ltra /usr/bin/gcc
lrwxrwxrwx 1 root root 6 Aug 5 2021 /usr/bin/gcc -> gcc-11
(lf) john@johns-laptop:/usr/bin$ ls -ltra /usr/bin/gcc-1?
lrwxrwxrwx 1 root root 23 May 1 2022 /usr/bin/gcc-11 -> x86_64-linux-gnu-gcc-11
lrwxrwxrwx 1 root root 23 May 13 2022 /usr/bin/gcc-12 -> x86_64-linux-gnu-gcc-12
lrwxrwxrwx 1 root root 23 Jul 19 2022 /usr/bin/gcc-10 -> x86_64-linux-gnu-gcc-10
lrwxrwxrwx 1 root root 23 Jul 11 2023 /usr/bin/gcc-13 -> x86_64-linux-gnu-gcc-13
(lf) john@johns-laptop:/usr/bin$ ls -ltra x86_64-linux-gnu-gcc-1?
-rwxr-xr-x 1 root root 862976 May 1 2022 x86_64-linux-gnu-gcc-11
-rwxr-xr-x 1 root root 1313952 May 13 2022 x86_64-linux-gnu-gcc-12
-rwxr-xr-x 1 root root 826088 Jul 19 2022 x86_64-linux-gnu-gcc-10
-rwxr-xr-x 1 root root 1018800 Jul 11 2023 x86_64-linux-gnu-gcc-13
(lf) john@johns-laptop:/usr/bin$ 

```

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [April 4, 2024, 5:36am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/30 "2024-04-04T05:36:05Z")

</div>

@Harper, it looks like your C compiler failed with:

```auto
    cc: fatal error: cannot execute ‘cc1’: execvp: No such file or directory

```

You are compiling LFortran from source code, which is only needed if you want to help develop it. If you want to use it as a user, then I recommend to install it using conda itself:

```console
conda create -n lf2 -c conda-forge lfortran
conda activate lf2

```

---

<div class="post-metadata">

**Author:** ![Harper](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@Harper](https://fortran-lang.discourse.group/u/Harper)\
**Post date:** [April 4, 2024, 7:14am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/31 "2024-04-04T07:14:01Z")

</div>

Thank you @certik. My hello.f90 program worked as expected but then I tried another one which lfortran complained had a syntax error. I reported that as suggested.

But now I find on opening another window in my Ubuntu Linux system that there is no file or directory called lf2 and the lfortran command gave this response:

```auto
(base) john:~$ lfortran hello.f90
Command 'lfortran' not found, did you mean:
  command 'gfortran' from deb gfortran (4:11.2.0-1ubuntu1)
Try: sudo apt install <deb name>
(base) john:~$ 

```

Am I supposed to issue those 2 lines of conda commands every time I open a new window?

(By the way I have no idea why (base) appears in my prompt: I started getting it a few days ago without me telling it to, and in the window I issued those conda commands it was replaced by (lf2)

---

<div class="post-metadata">

**Author:** ![Pranavchiku](https://avatars.discourse-cdn.com/v4/letter/p/cab0a1/32.png) [@Pranavchiku](https://fortran-lang.discourse.group/u/Pranavchiku)\
**Post date:** [April 4, 2024, 12:05pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/32 "2024-04-04T12:05:35Z")

</div>

Thanks @Harper for trying out! (base) indicates base environment, this happens when you update conda, it automatically activates the base environment upon startup.

To fix the problem you are facing, switch to `lf2` ( assuming here you have successfully installed LFortran ) by executing `conda activate lf2`, [verify by ( lf2 ) in place of ( base )] and then run your command.

---

<div class="post-metadata">

**Author:** ![Harper](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@Harper](https://fortran-lang.discourse.group/u/Harper)\
**Post date:** [April 4, 2024, 10:49pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/33 "2024-04-04T22:49:00Z")

</div>

Thank you @Pranavchiku. If anyone else has had my problem they might like to know that I have now put  
`conda activate lf2`  
at the end of my .bashrc file, and it works. I think of it as lfortran’s equivalent of Intel’s  
`source /opt/intel/oneapi/setvars.sh`  
which is also in my .bashrc to allow compilation with ifort and ifx. Using several compilers is good for hunting both my bugs and compilers’ bugs.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [April 5, 2024, 3:30pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/34 "2024-04-05T15:30:38Z")

</div>

> [@Harper](#):
>
> Using several compilers is good for hunting both my bugs and compilers’ bugs.

Absolutely. The more independent compiler toolchains, the better. Ensuring the Fortran code is truly multiplatform, not tied to any one compiler, and hopefully being able to compile years from now.

---

<div class="post-metadata">

**Author:** ![Shahid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahid/32/3672_2.png) [@Shahid](https://fortran-lang.discourse.group/u/Shahid)\
**Post date:** [August 5, 2024, 5:19am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/35 "2024-08-05T05:19:09Z")

</div>

I have a problem with LFortran installation too.

Following the [Installation — LFortran](https://docs.lfortran.org/en/installation/#build-from-git-on-windows-with-visual-studio)

 ![lFortran](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/4/4bf7c3b190bada0e8cf51bce883c62ae675658f2.png)

 ![miniforge](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/a/a6f20ce01bfcbcda63bb5de7a53bfb1b17032392.png)

I checked the Git prompt and it seems to work:  
 ![Git](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/3/32630112d2b78736002d8132b5a92c9a611b7730.png)

---

<div class="post-metadata">

**Author:** ![davidpfister](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/davidpfister/32/3949_2.png) [@davidpfister](https://fortran-lang.discourse.group/u/davidpfister)\
**Post date:** [August 5, 2024, 6:42am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/36 "2024-08-05T06:42:55Z")

</div>

You are facing the same problem as what you described using fpm and the intel compiler. Because you installed git in your mingw environment, it is not in the Windows path. That’s what the error message is about.  
You can either add the current git installation folder into the PATH variable, or reinstall git using [chocolatey](https://community.chocolatey.org/packages/git.install) or [winget](https://winget.run/pkg/Git/Git) for instance. If you do so, do it from the cmd or powershell terminals, not using msys2.  
MinGW acts as a subsystem on windows and as such environmental variables from MinGW are not accessible from Windows and vice versa. It’s your responsibility to add the required folders to PATH.

---

<div class="post-metadata">

**Author:** ![Shahid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahid/32/3672_2.png) [@Shahid](https://fortran-lang.discourse.group/u/Shahid)\
**Post date:** [August 5, 2024, 6:48am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/37 "2024-08-05T06:48:39Z")

</div>

If I drop the idea of using windows for Fortran and go back to Linux, would it be easy to use fpm,Lfortran,intel with fpm? Or Linux is supposed to have all these extra terminals there too?

---

<div class="post-metadata">

**Author:** ![davidpfister](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/davidpfister/32/3949_2.png) [@davidpfister](https://fortran-lang.discourse.group/u/davidpfister)\
**Post date:** [August 5, 2024, 6:54am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/38 "2024-08-05T06:54:40Z")

</div>

I personally have 0 experience with Linux but considering that most fortraners program on Linux my guess is that it’s fairly easy.  
As for Windows, the best experience you can get IMHO is intel+visual studio (not vscode). Your difficulties come from the mixed environment MinGW/Windows. There is some manual steps required to make it work that are not always obvious.

---

<div class="post-metadata">

**Author:** ![davidpfister](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/davidpfister/32/3949_2.png) [@davidpfister](https://fortran-lang.discourse.group/u/davidpfister)\
**Post date:** [August 5, 2024, 7:00am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/39 "2024-08-05T07:00:02Z")

</div>

Did you consider using this [link](https://github.com/LKedward/quickstart-fortran) for Windows?

---

<div class="post-metadata">

**Author:** ![Shahid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahid/32/3672_2.png) [@Shahid](https://fortran-lang.discourse.group/u/Shahid)\
**Post date:** [August 5, 2024, 7:03am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/40 "2024-08-05T07:03:11Z")

</div>

I was fine using windows cmd for gfortran and intel cmd for intel compiler. The idea of using new compiler LFortran brings another terminal. Same is the case with fpm that comes with another terminal. Now connecting all to check the code with different compilers is so difficult. The new developments are exciting but definitely not easy to follow for a novice Fortran programmer.

---

<div class="post-metadata">

**Author:** ![Shahid](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahid/32/3672_2.png) [@Shahid](https://fortran-lang.discourse.group/u/Shahid)\
**Post date:** [August 5, 2024, 7:21am UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/41 "2024-08-05T07:21:45Z")

</div>

> [@davidpfister](#):
>
> Did you consider using this [link](https://github.com/LKedward/quickstart-fortran) for Windows?

No

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [August 5, 2024, 2:26pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/42 "2024-08-05T14:26:04Z")

</div>

You can use WSL on Windows, I use it and it works fine.

---

<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:** [August 5, 2024, 2:57pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/43 "2024-08-05T14:57:42Z")

</div>

For pure windows I have moved to relying mostly on PowerShell, it includes git (at least for me with windows11), so no longer need to use different terminals for that. You can use WSL for testing with Linux, but it will not be a replacement for native windows deployment, simply a means to check that your codes are robust across both platforms.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [August 5, 2024, 4:30pm UTC](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440/44 "2024-08-05T16:30:03Z")

</div>

@hkvzjal yes, WSL is not a replacement for native Windows. It’s just that currently the native Windows experience is not as friendly as Linux or macOS, so it might not be a bad idea to start with WSL, and only then try to migrate to native Windows. LFortran itself builds and runs everywhere.

[Previous page](https://fortran-lang.discourse.group/t/i-have-a-problem-with-lfortran-installation/2440.md?page=1)
