Re: gfortran on linux



On Oct 11, 2009, at 5:16 PM, frank@xxxxxxxxxxxxxxx wrote:
dan@dan-desktop:~$ ls
Bliss.bmp Documents Music Public Templates
Desktop examples.desktop Pictures source Videos
dan@dan-desktop:~$ cd source
dan@dan-desktop:~/source$ dir
dan@dan-desktop:~/source$ ls
dan@dan-desktop:~/source$ gcc -c -Wall -Wextra d2.c
d2.c: In function ‘copy’:
d2.c:3: warning: type of ‘in’ defaults to ‘int’
d2.c:3: warning: type of ‘out’ defaults to ‘int’
d2.c:4: warning: passing argument 1 of ‘strcpy’ makes pointer from
integer without a cast
d2.c:4: warning: passing argument 2 of ‘strcpy’ makes pointer from
integer without a cast
dan@dan-desktop:~/source$ ls
c2.f03 d2.c d2.c~ d2.o
dan@dan-desktop:~/source$ gfortran c2.f03 d2.o -Wall -Wextra -o out
dan@dan-desktop:~/source$ out
bash: out: command not found
dan@dan-desktop:~/source$ ls
c2.f03 d2.c d2.c~ d2.o out
dan@dan-desktop:~/source$ run out
bash: run: command not found
dan@dan-desktop:~/source$ fortran c2.f03 d2.o -Wall -Wextra -o out.exe
bash: fortran: command not found
dan@dan-desktop:~/source$ gfortran c2.f03 d2.o -Wall -Wextra -o out.exe
dan@dan-desktop:~/source$ out
bash: out: command not found
dan@dan-desktop:~/source$

Besides not typing the right commands sometimes, I seem to need to do
something to make my shell fire up executables. What does one do with
.bashrc to make out work?

Linux doesn't care about the .exe extension. Instead, it uses mode
bits, one of which is 'execute'. Any executables produced by your
compiler will automatically have the execute bits set so you don't
need to worry about that.

The reasons you can't run out.exe above are twofold: you need to use
the full name (out.exe) and since the current directory (source) isn't
in your path, you need to provide a full absolute or relative path
to out.exe (in your case, ./out.exe is what you're looking for since
a dot denotes the current directory).

So, you should drop the .exe extension and use '-o out' instead. Then,
to run the program just type ./out. The dot slash looks funny at first
but it's standard practice. When you install things in the usual $PATH
locations like /usr/bin, or perhaps $HOME/bin, you no longer have to
do this.

--
Jason Blevins
Ph.D. Candidate, Department of Economics, Duke University
http://jblevins.org/
.



Relevant Pages

  • Re: gfortran on linux
    ... integer without a cast ... bash: out: command not found ... something to make my shell fire up executables. ...
    (comp.lang.fortran)
  • Re: USB neu starten
    ... PCI Interrupt Link enabled at IRQ 7 ... bash: SLPB: command not found ... bash: syntax error near unexpected token `supports' ... achim@achim:~$ ReiserFS: hdc5: found reiserfs format "3.6" with standard journal ...
    (de.comp.os.unix.linux.hardware)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.30)
    ... This is the Bash FAQ, version 3.30, for Bash version 3.0. ... Bash, the GNU Bourne-Again Shell. ... C3) Which new features in ksh-93 are not in bash, ... D1) Why does bash run a different version of `command' than ...
    (comp.unix.questions)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.25)
    ... This is the Bash FAQ, version 3.25, for Bash version 2.05b. ... Bash, the GNU Bourne-Again Shell. ... C3) Which new features in ksh-93 are not in bash, ... D1) Why does bash run a different version of `command' than ...
    (comp.unix.questions)
  • [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.26)
    ... This is the Bash FAQ, version 3.26, for Bash version 2.05b. ... Bash, the GNU Bourne-Again Shell. ... C3) Which new features in ksh-93 are not in bash, ... D1) Why does bash run a different version of `command' than ...
    (comp.unix.questions)