answersLogoWhite

0


Best Answer

You start by writing your c code in a text editor. An example of some c code (syntax not guaranteed to be correct):

#include <stdio.h>

int main ();

{

printf("Hello, World!!\n");

return 0;

}

Then, you save this file, as whatever, for this example as 'Hello.c'.

Then, open a Terminal window (command line) and change your directory to where your Hello.c is saved at, using 'CD <filepath>' (sans brackets). Then, type 'gcc Hello.c -o Hello'. The 'gcc' command compiles your code, and the -o flag changes the output filename to whatever you specify, in this case Hello. Then, to run your new program, type './Hello'. The ./ specifies the current directory.

Congrats, you have written, compiled, and ran your first program in C using a Linux platform.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How is compiler and run of Linux c program with example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you write a C program which runs independent of the compiler No need to install the compiler?

Any computer program does not need compiler at the time of execution. Compiler is needed to convert a high-level language program into an intermediate machine code. When you run a program, the executable binary runs, and that is what you get after compilation, etc. Summary: your Q is incorrect. Please read about compiler, and linker to understand the concept. You cannot write c or c++ code and run it without a compiler. a compiler translates a high level language (c, c++, java) into basic computer code (binary) which is composed of 1's and 0's (101001111001). but you can run it without a compiler if it has already been turned into an executable or an application by another computer.


What is the use of c compiler in windows?

The c compiler in Windows converts the binary code from source files. C is a compiled programming language and it needs to be converted for the program to run.


What is a compiler in c program?

The compiler is software that allows any high-level language to be translated into the machine language, compilers are language specific, i.e. C language has its own compiler which will translate the code written in C language to the machine language, compiler for Java will do the same task for the Java code


When using CodeBlocks IDE for Linux how do you compile the program you are writing as an EXE?

CodeBlocks is an extensible, cross-platform IDE but it does not come with a compiler nor a linker since they are platform-specific. When you first run the IDE, it will scan your system for all supported compilers and integrate them into your IDE If you have more than one supported compiler, then you must choose the master compiler. But if you have no compiler, then you must add one. To build an EXE you must configure the project's compiler and linker switches according to your chosen compiler. Consult the compiler's own documentation for more information on this.


C programming are converted into machine language with the help of?

A software tool called a "compiler" translates C programs into the underlying machine language for the system you are using. The C program is called "source code" and the compiled program is called "object code". If you compile a program that will run on a completely different type of system, then it's called "cross compiling." Cross compiling requires a special compiler. For example, when you compile an application for the iPhone, you're compiling it on an computer that uses an Intel processor, but the actual program will run on an ARM based processor.

Related questions

Can you install C language in Linux?

C isn't a program, or something you install; it is a programming language for writing software. Linux and most of the programs that run on it were written in C, and a C compiler and libraries are supplied with most systems, or are readily available.


Can i run c compiler on windows7 if yes then on Which tool?

Sure, if the compiler is written for Windows32 or Windows64. You cannot run compilers written for other platforms (MsDos, Windows16, linux, etc).


What is run time in java?

That refers to anything that happens while you run the program. For example, the compiler may detect certain problems while you compile the program, but certain errors are bound to happen only when you actually run the program - i.e., at runtime.


What command should be given to run a C program from the DOS prompt?

This depends on what compiler you're using, but they all generally have the same process. Example: Converts source code stored in the file test.c into an executable program in test.exe using the GCC compiler... gcc -o test.exe test.c To run the program you can now just run test.exe.


What is Linux wine and what is it used for?

Linux Wine is an open source software program. The Linux Wine software program allows Linux users to run Windows programs on their own devices such as computers.


What is language migrator?

language migrator makes a program compatible to all the operating systems. For example a program written in windows can run in linux using language migrator.


How do you write a C program which runs independent of the compiler No need to install the compiler?

Any computer program does not need compiler at the time of execution. Compiler is needed to convert a high-level language program into an intermediate machine code. When you run a program, the executable binary runs, and that is what you get after compilation, etc. Summary: your Q is incorrect. Please read about compiler, and linker to understand the concept. You cannot write c or c++ code and run it without a compiler. a compiler translates a high level language (c, c++, java) into basic computer code (binary) which is composed of 1's and 0's (101001111001). but you can run it without a compiler if it has already been turned into an executable or an application by another computer.


Does OpenOffice.org run on Linux?

Yes, OpenOffice.org can run on Linux and some like Ubuntu include this office program.


Can you run an ASP program on Unix or Linux?

http://www.apache-asp.org/


Can you run Linux applications on Windows?

Yes, if the program is open source.


How do you run an windows or mac program on Linux?

You don't run macOS applications on Linux unless there's a Linux port. As far as Windows goes, there is Wine. Do note that it's not an emulator and it won't run perfectly with everything.


Why c compiler creates exe file?

(Actually, it is the linker, not the compiler.) In most cases, when you write a program, it's not only for your own pleasure, but you actually want to run the program. Well, the runnable format of the program is the exe(cutable).