Cannot run program other computer, compiled with gfortran

Hi all,

I compiled my Fortran program using Gfortran on a normal i5 10500 computer. After that, I moved the program (.exe) to a workstation that uses Xeon Gold 6312U. However, the program can’t run, saying libgcc_s_seh1.dll, libwinpthread-1.dll, libquadmath-0.dll are missing and reinstalling the program might solve the problem. I have some questions:

  1. Is this only happening to a workstation, or in general when I move Fortran program to other computers?
  2. In this case, I can actually install mingw to compile my program there. But, I also plan to share my program to my coworker that uses normal pc. It is quite hard to ask all of them to install mingw in their computers to just compile one program. Is there a solution to this (on general pcs)?
  3. Is there a solution on workstation pcs (if it’s different that on general pcs)?

Many thanks for your help~

Do not compile with options like -march=native and it should be fine. If you compile on one platform using the highest extension set available and then try to run on another that lacks said feature, your executable will not work.

It is also possible that your 2nd platform is missing some library that your executable is linked to dynamically, so when it tries to run a new machine lacking said library, whatever functions your program uses from it can’t be found, and wala error.

Reading your actual error message, it sounds like the second option is the problem you are experiencing. It’s telling you right there the problem. Libraries are missing on the second machine.

I’m not sure what environment variables windows uses, but on Linux I would put the missing shared object files (.so) somewhere on $LD_LIBRARY_PATH

You may also try to recompile your original program with the compiler flag -static. That should attempt to statically link everything and the resultant executable should run without needing extra libraries installed.

1 Like


Thanks for the answer. I don’t compile it with any options, only gfortran and then file.f90. Do you know how to install the libraries (is it the one included when we install MinGW), and is this library commonly installed on normal computers? I am running windows 10 on all machines. I will try the -static one. Many thanks~

Lots of compilers will dynamically link against some runtime libraries by default. Intel’s ifort also does this. Please report back the results from compiling with -static, as I believe that is going to be your best bet to produce a single executable that “just works” across multiple machines, at least on the same operating system.

1 Like

Those are standard MinGW libraries every gfortran executable should be aware of. By default, MinGW will just dynamically link those (and it does well to dynamically link them, if you ask me.) So if those libraries are not present in your computer (or aren’t located in a directory included in yout %PATH%) your program won’t run. This means even the computer you compiled the program won’t be able to run the executable unless said dynamically linked libraries can be found via your %PATH%. There are two ways to solve the “problem”:

  • Compile with -static included in your LDFLAGS. The libraries you mentioned will be statically linked and the program should run everywhere. If your program just uses standard MinGW libraries, this should be enough. However, if you also use other libraries not included in MinGW, you should have static versions of those too. Otherwise you will see messages similar to the ones you see now, just with other library names.
  • Copy the libraries missing from <MinGW_folder>\lib to the same directory your executable is located and distribute them together, as a folder. If the needed libraries are not found in %PATH% locations, the system will look for them in the same folder where the executable is, so it will work.

Please note that I am using GNU/Linux and FreeBSD for development and I use MinGW in… that other “operating system” only when I want to make sure my software works there too. So there might be other ways to solve the issue in systems I just don’t use myself, such as MSYS2 or Cygwin, or potentially others too.

If you want to make sure that your executables will run everywhere, do not install MinGW globally, even in the machine you are developing. What I do is to extract MinGW in a folder the system is not aware of (this can be in C: or in another drive other than C: - or even in an external drive/usb stick.) Then I run a batch file that adds MinGW, my editor/IDE of choice, and whatever else I need for development in my %PATH%. That way I have a system that is temporarily fully aware of MinGW and ready for development. Once the batch file is ended, the system is no longer aware of anything, and I can check if the executables still run, as if I were using someone else’s computer who doesn’t even have MinGW.

1 Like