Beginner and a makefile file

  • Fortran
  • Thread starter Vrbic
  • Start date
  • #1
381
11
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.
 

Answers and Replies

  • #2
FactChecker
Science Advisor
Gold Member
5,758
2,139
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.
 
  • #3
12,031
5,693
Yes try the command:
Code:
make ./makefile    

--or-- 

nmake ./makefile
 
  • #4
381
11
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.
 
  • #5
12,031
5,693
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:
  • #6
381
11
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.
 
  • #7
381
11
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...?
 
  • #8
12,031
5,693
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.
 
  • #9
FactChecker
Science Advisor
Gold Member
5,758
2,139
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.
 
  • #10
381
11
As usual a fortune helps. The desired command is (only) "make", if you are in folder where is everything needed.
Thank you all.
 
  • #11
DrClaude
Mentor
7,389
3,653
Yes try the command:
Code:
make ./makefile   

--or--

nmake ./makefile
You mean
Code:
make -f ./makefile
 
  • Like
Likes jedishrfu
  • #12
381
11
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.
 
  • #13
FactChecker
Science Advisor
Gold Member
5,758
2,139
Usually the makefile, directory structure, and locations of libraries make this much more complicated. But if putting everything in one directory works, that is excellent. That is often prevented by conflicting file names that would need to be changed along with any associated "include" statements.
 
  • Like
Likes Vrbic

Related Threads on Beginner and a makefile file

  • Last Post
2
Replies
34
Views
2K
  • Last Post
Replies
4
Views
784
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
3
Views
5K
  • Last Post
Replies
3
Views
13K
Replies
2
Views
6K
Replies
4
Views
7K
Replies
9
Views
2K
Replies
1
Views
3K
  • Last Post
Replies
2
Views
3K
Top