Forrest logo
back to the gfortran tool

gfortran:tldr:cf821

gfortran: Include libraries from a different path.
$ gfortran ${path-to-source-f90} -o ${path-to-output_executable} -I${path-to-mod_and_include} -L${path-to-library} -l${library_name}
try on your machine

This command is used to compile a Fortran source code file into an executable file using the GNU Fortran compiler (gfortran). Here is the breakdown of the command:

  1. gfortran: This is the command to invoke the GNU Fortran compiler.

  2. ${path-to-source-f90}: This is a placeholder indicating the path to the Fortran source code file you want to compile. You need to replace ${path-to-source-f90} with the actual path to your source code file.

  3. -o: This option specifies the output file name of the executable. ${path-to-output_executable} is a placeholder indicating the path to where you want to save the compiled executable file. You need to replace ${path-to-output_executable} with the desired path and name for your output file.

  4. -I${path-to-mod_and_include}: This option adds a directory to the list of directories searched for module files and header files. ${path-to-mod_and_include} is a placeholder indicating the path to the directory where your module files and include files are located. You need to replace ${path-to-mod_and_include} with the actual path to your module and include files directory.

  5. -L${path-to-library}: This option adds a directory to the list of directories searched for libraries. ${path-to-library} is a placeholder indicating the path to the directory where your library is located. You need to replace ${path-to-library} with the actual path to your library directory.

  6. -l${library_name}: This option specifies a library to link against during the compilation process. ${library_name} is a placeholder indicating the name of the library you want to link. You need to replace ${library_name} with the actual name of the library.

By executing this command, the gfortran compiler will compile the Fortran source code file, resolve module and include dependencies, link the required library, and generate an executable file specified by ${path-to-output_executable}.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the gfortran tool