-4

Could someone explain to me what is a.out and how it works? This is the first time I am using Unix (minix). I have one folder with two files filename.c and test.sh (containing three lines starting with ./a.out and some f=values). I just want to compile and execute filename.c if it is not?

Chris Seymour
  • 83,387
  • 30
  • 160
  • 202
user2085339
  • 145
  • 2
  • 9

4 Answers4

1

I don't use minux, so take it with a grain of salt, but it seems you should be using mcc for compilation*:

mcc filename.c -o myprogram
chmod +x myprogram
./myprogram

The -o option allows you to pick the exectable name so it's not defaulted to a.out, the chmod +x is to make sure that you have a valid exectuable (it might not be needed, but it won't hurt)

*Reference

Mike
  • 47,263
  • 29
  • 113
  • 177
1

I use ubuntu and compile using gcc.First i write the code and say I named it testing.c .Then I save it in a folder say c. then i go command line and if currently I m not in the folder c I change it to folder c by writing

cd /c

then i compile it using gcc

gcc testing.c -o testing

then next i rung it by typing

./testing

note:-this is what i do on ubuntu when compiling using gcc.

0

-> To compile after saving and exiting the program(ESC :wq) at command prompt the command is CC (Your filename needs to have an extension .C)

->To run the program at command prompt you need to type ./a.out.

->To compile and run without closing your program it is (ESC) :!CC % and (ESC) :!./a.out

U can have a look at here

0

The Unix custom is that if you call a compiler to generate an executable, and do not give the name of the executable explicitly, the executable is called a.out (presumably for assembler output). So:

  • cc -c program.c: Just compile, gives program.o
  • cc program.c: Compile and link, no executable name given, executable is a.out
  • cc -o name program.c: Compile and link, asked explicitly to give executable name

The compilers usually are smart enough to divine the contents (and thus how to handle files) from their extensions.

vonbrand
  • 11,412
  • 8
  • 32
  • 52