Why open a terminal to execute a.out?

  • Thread starter Avichal
  • Start date
In summary: Cygwin.In summary, the conversation is about how to run a code written in a different language on a computer. The person is asking why you have to open a terminal and then execute the code. The answer is that there is more to a desktop app than just the thing that is executed underneath the hood. The thing that is executed underneath the hood, in this case your a.out, still needs to exist as an entity of its own. Creating that executable file is (in this case) the job of the compiler. All the other stuff that collectively form a desktop app -- those are the job of other tool(s), not the compiler.
  • #1
Avichal
295
0
I use ubuntu for programming. I am learning C and till now all the programs I have made require me to open a terminal, compile using gcc and then execute the a.out file.

Why can't I just click the a.out and run it? Why do I have to open a terminal and then execute it?
Basically all the programs do is to take some input, manipulate it and produce an output. Input is taken through stdin and output through stdout. Is terminal the only way to connect to stdin and stdout?

Does my question make sense?
 
Technology news on Phys.org
  • #2
Avichal said:
Why can't I just click the a.out and run it? Why do I have to open a terminal and then execute it?
Because there's more to a desktop app than just the thing that is executed underneath the hood. The thing that is executed underneath the hood, in this case your a.out, still needs to exist as an entity of its own. Creating that executable file is (in this case) the job of the compiler. All the other stuff that collectively form a desktop app -- those are the job of other tool(s), not the compiler.
 
  • #3
Avichal said:
Why can't I just click the a.out and run it? Why do I have to open a terminal and then execute it?

Without a terminal, where would the input to stdin come from, and where would the output to stdout go to?
 
  • #4
D H said:
Because there's more to a desktop app than just the thing that is executed underneath the hood. The thing that is executed underneath the hood, in this case your a.out, still needs to exist as an entity of its own. Creating that executable file is (in this case) the job of the compiler. All the other stuff that collectively form a desktop app -- those are the job of other tool(s), not the compiler.

Are the other tool(s) called drivers? So when a terminal starts it calls the other tool(s) to do the other stuff?
 
  • #5
Avichal said:
Are the other tool(s) called drivers? So when a terminal starts it calls the other tool(s) to do the other stuff?
I wouldn't call drivers "tools". Drivers are extensions of the operating system so that it can send and receive data from the devices that are connected to the computer. There are drivers for the keyboard, mouse, display adaptor, hard drives, USB ports, network cards, and so on.
 
  • #6
Mark44 said:
I wouldn't call drivers "tools". Drivers are extensions of the operating system so that it can send and receive data from the devices that are connected to the computer. There are drivers for the keyboard, mouse, display adaptor, hard drives, USB ports, network cards, and so on.

So what are the other things required for a desktop app?
 
  • #7
Answer: Windowing. It is a large app. Windows runs explorer.exe which is the same idea.

You are confusing interface with terminal. The terminal has a simple interface - /dev/tty with stdin stdout, stderr.
Windowing works on events processing - from the mouse and the keyboard, for example.. Keyup, keydown, mouse over, Window focus etc.

I don't get your issue here. It's like saying why do I have to turn on my computer and type? Why it this a problem? Do you have to create a terminal everytime you run code? Can you not leave the terminal open and minimized.
 
  • #8
jim mcnamara said:
Answer: Windowing. It is a large app. Windows runs explorer.exe which is the same idea.

You are confusing interface with terminal. The terminal has a simple interface - /dev/tty with stdin stdout, stderr.
Windowing works on events processing - from the mouse and the keyboard, for example.. Keyup, keydown, mouse over, Window focus etc.

I don't get your issue here. It's like saying why do I have to turn on my computer and type? Why it this a problem? Do you have to create a terminal everytime you run code? Can you not leave the terminal open and minimized.

I have no problem leaving my terminal open and minimized!
I was just curious to know what is actually happening in the back-end.
 
  • #9
About 20 years ago, I did some programming in Fortran, C++ etc. under "classic" Mac OS, before the Unix-like OS X with its Terminal application came into being. The programming system had an option to generate either a normal Mac OS application, in which case the programmer had to write code for windows, I/O, etc.; or a "console application", in which case your compiled code was linked with pre-compiled library code for a simple terminal-like application that could be double-clicked in order to run it. This console window did not have a command line like the Unix/Linux xterm, but only provided for standard input via the keyboard and standard output via the window.

I've never seen this done under *nix, but it ought to be possible in principle.
 
  • #10
Avichal said:
Why can't I just click the a.out and run it?
Is there some way in *nix to associate a *.out file as a runnable console program?

jtbell said:
under "classic" Mac OS, before the Unix-like OS X with its Terminal application came into being. The programming system had an option to generate either a normal Mac OS application, in which case the programmer had to write code for windows, I/O, etc.; or a "console application", in which case your compiled code was linked with pre-compiled library code for a simple terminal-like application that could be double-clicked in order to run it. This console window did not have a command line like the Unix/Linux xterm, but only provided for standard input via the keyboard and standard output via the window.
You could have used Macintosh Programmer's Workshop (MPW), wiki article:

wiki_mpw.htm

I always thought it was strange that MPW, used to create GUI programs for the Mac, ran under a dos console like window with a conventional command line interface. There were other GUI based compilers, like Think C, and even a 4th generation language, Prototyper (the programmer created a user interface via a drag and drop GUI interface, and Prototype would generate the code), and both of these had "proper" GUI interfaces, similar to the IDE's of current tool sets.
 

FAQ: Why open a terminal to execute a.out?

1. Why do I need to use a terminal to execute a.out?

The terminal is a command-line interface that allows you to communicate directly with your computer's operating system. In order to execute a.out, which is an executable file, you need to use the terminal to enter the necessary commands to run the program.

2. Can't I just double-click on a.out to run it?

No, double-clicking on a.out will not work because it is an executable file and not an application. Double-clicking is typically used to open and run applications with a user-friendly graphical interface, whereas a.out requires specific commands to be entered through the terminal.

3. What exactly is a.out and why do I need to execute it?

a.out is the default name given to an executable file generated by a C or C++ compiler. This file contains the compiled code of your program and needs to be executed in order to run your program and see the output.

4. Is using a terminal the only way to execute a.out?

No, there are other ways to execute a.out such as using a debugger or an integrated development environment (IDE). However, using a terminal is the most common and straightforward method for executing a.out.

5. Can I use a terminal on any operating system to execute a.out?

Yes, the terminal can be used on any operating system, including Windows, MacOS, and Linux. However, the commands used to execute a.out may differ slightly depending on the operating system.

Similar threads

Replies
2
Views
996
Replies
9
Views
3K
Replies
34
Views
4K
Replies
9
Views
2K
Replies
9
Views
3K
Replies
6
Views
2K
Replies
1
Views
4K
Replies
15
Views
5K
Back
Top