How to write files for compiling a program.?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to write files for compiling a program.?
# 1  
Old 05-22-2013
How to write files for compiling a program.?

I am hoping someone can give me a good free web resource for writing code to compile a binary executable. I am getting fairly decent at writing shell script, are the .f files just shell scripts? Also, I don't know where to begin on the makefiles. The reason I am curious is because I have been tasked with fixing a binary.x and the code looks foreign. The use C instead of # for comments, does this mean it is in the csh? Any help is appreciated, thanks.
# 2  
Old 05-22-2013
I'm pretty sure .f files are Fortran, no relation to the C shell or any other shell.

If you have gcc fortran, I think you would do
Code:
gfortran file.f -o file

Perhaps more than one .f file would need to be listed for a complete program, depends on the program.

You can also take two steps, and do
Code:
gfortran -c file.f
gfortran file.o -o file

Makefiles are pretty simple in the end, you tell them what files are made from what files.

With this file named Makefile in the same directory, run make:

Code:
# Rule that converts any .f files into .o files
%.o : %.f
        gfortran -c %< -o %@

# Convert these four .o files into one executable
program:a.o b.o c.o d.o
        gfortran a.o b.o c.o d.o -O program

Note that things with eight space in front here are actually tabs and MUST BE tabs.

Last edited by Corona688; 05-22-2013 at 02:00 PM..
# 3  
Old 05-22-2013
Okay thanks! that actually seem very straight forward. But the real problem I'm having is within the files that make up the executable. Do you know of a website that can help me understand the commands that are within those files and such?
# 4  
Old 05-22-2013
Which problem? Be specific. It might not be anything to do with the program. Or might have to do with the way you're compiling it. I can't see your computer from here.

Fortran is a programming language which you will need to learn if you wish to debug it. It doesn't resemble shell.
# 5  
Old 05-22-2013
That is the thing, I need to understand the programming language to find the problem. I realize it may not be the program, but I can't know that if I don't know what the program is telling the computer to do. The reason for my post is to see if anyone could provide a good source for me to learn the language so that I can figure out the problem. I apologize if I am making this difficult. I'm still learning this stuff and it is hard for me to discern what is relevant and what is not.

---------- Post updated at 02:09 PM ---------- Previous update was at 01:16 PM ----------

For anyone else that sees this and needs a reference, I found one here. Thank your help Corona688.
# 6  
Old 05-22-2013
Thank you for posting that, I kept finding compiler instructions instead of fortran ones...
# 7  
Old 05-22-2013
Quote:
Originally Posted by butson
Also, I don't know where to begin on the makefiles.
If you need a (very) short introduction into using "make" and its makefiles you might want to read this introduction i wrote. Real-world makefiles are a lot more complicated than this but it gets you at least started on the idea.

I hope this helps.

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

compiling old C program in Linux.

Hello, I am writing to ask for support about compiling an very old but famous C-progam for genetics study called MapMaker/QTL, and the source code is available from MIT: http://www.broadinstitute.org/ftp/distribution/software/mapmaker3/The program was originally designed for systems like SunOS... (1 Reply)
Discussion started by: yifangt
1 Replies

2. UNIX for Dummies Questions & Answers

write a program in c in unix that display the files(includ sub-direc and files within) in a sorted

the sorting is based on name of file, file size modification time stamps o f file it should dislay the output in the following format "." and ".." enteries should be ignored please give some idea how to do it (1 Reply)
Discussion started by: pappu kumar jha
1 Replies

3. Programming

Problems compiling OpenStep program.

I use Ubuntu 10.4, and I installed GNUStep, Gorm (a gui builder) and ProjectCenter (the GNU alternative to Xcode) because I want to develop Objective-C apps. I opened the ProjectCenter and I created an application that displays only an empty window. I sourced the GNUstep.sh and I compiled the app. ... (0 Replies)
Discussion started by: mghis
0 Replies

4. Shell Programming and Scripting

Write an automated shell program(s) that can create, monitor the log files and report the issues for

Hi , Please help me getting this done. Write an automated shell program(s) that can create, monitor the log files and report the issues for matching pattern. (i) Conditions for creating log files. Log file is created with date (example 2010_03_27.log). If the log file size is 10 Mb for... (1 Reply)
Discussion started by: itian2010
1 Replies

5. Programming

compiling c program in unix

if somebody can help me pls. i need the source code for a shell which compiles C or java programs in unix i need a very short and simple one, just the compiling part Respect (2 Replies)
Discussion started by: zlatan005
2 Replies

6. Programming

help on compiling a C program on Tiger

here is the very simple bob.c: main() { printf("hello"); } i use tiger and i use the command: gcc bob.c and the end result: bob.c: In function ‘main': bob.c:3: warning: incompatible implicit declaration of built-in function /‘printf' any help appreciated, i'm just starting... (4 Replies)
Discussion started by: cleansing_flame
4 Replies

7. Programming

Compiling a C program

Help I know nothing about c programming. :confused: I want to compile the below c program. It extracts data from an oracle database into csv files. I have oracle 9206 installed with ProC. I dont have gcc My question is. How the hell do I make this into an file I can run? I am pulling... (3 Replies)
Discussion started by: ooploo
3 Replies

8. Programming

Problem compiling program

hi i am having a problem that when ever i use cc program_name.c to compile a program. an error occurs, showing cc not found. please help. (28 Replies)
Discussion started by: rochitsharma
28 Replies

9. Programming

Compiling a program

Hello. I am trying to run a c program on a unix shell (ssh). I have searched this forum but have not come accross the soultion to my problem, so I am posting my question here :cool: I wrote the following simple code: #include <iostream.h> using namespace std; int main() { ... (7 Replies)
Discussion started by: Minnesota Red
7 Replies

10. Programming

Error Compiling C program

Hi All, I tried to compile a C program but i am getting error while Linking . it says Undefined reference to ' ' (here it gives a method name which is defined Globally ). Can any body tell the resaon and remedy for the same . Iam stuck up here . Thanks (3 Replies)
Discussion started by: Vivek
3 Replies
Login or Register to Ask a Question