# Beginner and a makefile file

• Fortran
Hello,
I'm young physicist and I have had a first contact with program in fortran. It is not my code but I have got an assignment to use that for my purpose. I can program in C. I watched few videos lessons for beginers about fortran and I hope I understand a structure and common commands. Now I have big code to produce some tables which are important for me. In folder are sources *.f some tables *.atb and makefile *.
I'm using windows 7 and cygwin terminal for that purpose. I mostly understand the commands but I don't have any idea how to produce executable file from makefile or something help me to produce my desire tables.
Maybe it may seems stupide but for me isn't important understand all, just produce table from that code, if it is possible without deep studing. If not I will study.

I tried to run a makefile in this terminal (I guess it is same as in linux)
"./makefile" and result was that any uncommented line was an error.

Thanks for a help, an advice, anythink.

Related Programming and Computer Science News on Phys.org
FactChecker
Gold Member
Are you working in an environment where you have compiled and built your program? If so, there should be an executable .exe file that you can run within that environment or from the command line. That environment will probably use a makefile or some other equivalent, but you probably don't have to know about them till you are more experienced.

Makefiles can usually be executed directly with the "make" of "nmake" command.

jedishrfu
Mentor
Yes try the command:
Code:
make ./makefile

--or--

nmake ./makefile

Are you working in an environment where you have compiled and built your program? If so, there should be an executable .exe file that you can run within that environment or from the command line. That environment will probably use a makefile or some other equivalent, but you probably don't have to know about them till you are more experienced.
I didn't write this code. My attempts of fortran code (as "Hello world" but also more complex) were written in text editor and comapiled in linux environment cygwin ( https://en.wikipedia.org/wiki/Cygwin ) using command gfortran "*.* -o filename". Now I don't know how in this cygwin run a makefile.

jedishrfu
Mentor
It says "make in the wikipedia article is part of MinGW:

Alternative Windows/Unix integration tools
Several open-source and proprietary alternatives provide simultaneous access to both Windows and UNIX environments on the same hardware.

Toolsets like Windows Subsystem for Linux, Microsoft Windows Services for UNIX (SFU), UWIN, MKS Toolkit for Enterprise Developers and Hamilton C shell also aim to provide a Unix-like user- and development-environment. They implement at least a shell and a set of the most popular utilities. Most include the familiar GNU and/or Unix development tools, including make, yacc, lex and a cc command which acts a wrapper around a supported C compiler. SFU also includes the GCC compiler.

https://en.wikipedia.org/wiki/Cygwin
try using the "which" command to see if make is present: "which make"

Last edited:
Yes try the command:
Code:
make ./makefile

--or--

nmake ./makefile
I tried that but for both command not found if I do only ./makefile it runs but every line is command not found.

It says "make in the wikipedia article is part of MinGW:

try using the "which" command to see if make is present: "which make"
Now I don't understand...the link is wrong or...?

jedishrfu
Mentor
I tried that but for both command not found if I do only ./makefile it runs but every line is command not found.
A makefile is not a runnable script, its an input to the "make" command explaining to make how to build your program, what source files to compile, what libraries are needed and how to link everything together. Basically make runs other commands like gfortran... to build your executable file.

FactChecker
Gold Member
Trying to build a large program on a new machine can be difficult even with a makefile. The program is likely to need many libraries that are in different places or not even on your machine. In that case, the makefile would need to be changed and libraries may need to be installed.

As usual a fortune helps. The desired command is (only) "make", if you are in folder where is everything needed.
Thank you all.

DrClaude
Mentor
Yes try the command:
Code:
make ./makefile

--or--

nmake ./makefile
You mean
Code:
make -f ./makefile

jedishrfu
You mean
Code:
make -f ./makefile
In my case is right command:
Code:
make
If and only if you are in folder where are all included files and file makefile.

FactChecker