C++Introduction to C++Learn C++

How To Compile And Run A C Program In Terminal

The C programming language is one of the most popular and versatile programming languages. The C Programming Language was developed in the 1970s and since 1970, C has inspired the invention of a vast array of other programming languages, such as C++. The C++ programming language includes a substantial number of elements of the C language and builds on those solid foundations with object-oriented programming features like Classes, Objects, and Methods. Still, this oldest genie language is popular, mostly in the top 3 but if we consider its other variations and its usage on microchips and IoTs it is the most used programming language.

C and C++ Compilers are great tools to develop when they are paired with a professional C++ IDE such as RAD Studio and C++ Builder.

What is a C or C++ compiler?

A C or C++ Compiler is a computer program that converts the high-level instructions of the programming language (i.e. C/C++ source code) written with text into executable machine code in partnership with a linker. In general, all computers work with machine code executable packages – code that can be directly run by the operating system. This is the most low-level and fastest code, but it requires writing many lines for simple things and is hard to generalize for all kinds of machines.

Is a C++ IDE the same as a C++ compiler?

The term C++ IDE refers to the entire integrated development environment. Technically. the compiler is the part of the C++ IDE which interprets the program’s source code and converts it in object code. This object code is the ‘linked’ by another related process called, perhaps unimaginatively, the linker. The entire C++ IDE includes the specialized text editor in which the programmer writes the program’s source code and designs the screen layouts as well as menu options or shortcuts to tell the C++ compiler to compile the source code and the linker to link it into the final program executable or app package.

Are a C compiler and C++ compiler different?

Most C compilers only ‘understand’ programs written in the C programming language. However, since C++ is a mostly a kind of superset of the C language you will find that the C++ compiler can compile nearly all C programs too. This is definitely the case for C++ Builder which can compile both C and C++ source code without any problems at all.

How can I download the latest C++ Builder for free to compile and run a C program?

The C++ Builder CE version is free C and C++ IDE for building simple or professional applications on the Windows, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. C++ Builder comes with Rapid Application Development Studio, also known as RAD Studio, and C++ Builder is one of the most professional IDEs that work under RAD Studio. C++ Builder comes from a venerable history which began with the incredibly popular Borland TurboC in 1990. This was later renamed Borland C++ Builder. Under the Embarcadero brand, it comes with new versions, features, updates, and support. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey FMX framework for cross-platform UIs. There is a free C++ Builder Community Edition for students, beginners, and startups.

How To Compile And Run A C Program In Terminal - the RAD Studio C++ IDE
RAD Studio / C++ Builder 11.1 Patch 1 IDE and Compiler, Welcome Screen

Here are the features of the C++ Builder 11 version;

  • Provision apps for Windows 11
  • Compile for Android API 30
  • Compile for M-series (Apple Silicon) processors
  • Design on high-DPI 4k+ screens
  • View VCL Styles in design time
  • New & modernized VCL components  
  • Use enhanced remote desktop support to collaborate remotely 

You can download the free C++ Builder Community Edition here: https://www.embarcadero.com/products/cbuilder/starter.
Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://www.embarcadero.com/products/cbuilder.

See What’s New in C++ Builder 11

Download C++ Builder 11 Now

How to compile and run a C program in terminal with the C++ Builder IDE?

You can use C++Builder to develop a C console application, or to develop a C++ console application or a C++ Visual Application with GUIs like buttons, edit boxes etc. C++ Builder is a good tool to develop C and C++ applications from the beginner level to higher professional levels.

How to start coding in C++ Builder to compile and run a C program for the terminal or command line

  1. Install and Run the latest RAD Studio or C++ Builder CE
  2. Create a new Console Application from the File->New->Console Application C++ Builder menu as below,
How To Compile And Run A C Program In Terminal - creating a console application

3. In the next window, select Target Framework as None and If you are sure you will use C language only then you can select C language. If you want to use C language and may be you can use C++ features in the same code, then you can select C++ source type. And press OK to create a new application.

How To Compile And Run A C Program In Terminal - picking the target framework

4. Now, you can start to write your first C codes into Code Editor of C++ Builder IDE. Here is a simple Hello World example as below,

How To Compile And Run A C Program In Terminal -a hello world C program in the C++ Builder IDE
RAD Studio / C++ Builder IDE 11.1.5

Here first add library headers with #include < > command. Then we define our main() program with { and } .Between these we write our main program. We can use printf(” “); function to write text outputs. Then we can wait for a character input (a key press) by the getchar(); command. Finally we can write return 0; to let application know it is done successfully. If you have problem to type you can use this full example below.

5. Now we can compile and run our application. Press Run Button or just Press F9 to compile and run your first C example.

How To Compile And Run A C Program In Terminal - the output from the C hello world program in in the terminal windows

How to compile and run a C program in the Terminal or command line with the RAD Studio Command Prompt and MSBuild?

If you create and save your C++ Builder C development project as described above, you can run RAD Studio Command Prompt.

1. First be sure that RAD Studio or C++ Builder is installed and the project and C files of this project is saved in a folder.
2. Press Windows Key and write “RAD” then in Windows Menu choose” RAD Studio Command Prompt”. This will execute Command Prompt with RAD Studio settings.
3. Use CD command to navigate to your project folder. For example,

4. type dir command to see your C project files
5. *.cbproj file is your project file. Use msbuild to use MS Build app. This will build your application with project settings, it will use appropriate c compiler and linker defined in this project file. For example,

6. This will compile and list you errors and warnings as given example below,

How To Compile And Run A C Program In Terminal - the RAD Studio command prompt

7. The executable file is generated in an output folder. This folder can be Win32, Win64, iOS, Android etc. You can check these folders by cd and dir commands. And also project can be in Debug or Release folders, depends on your project. Our project was 32bit Windows Console Application (Win32) and it was in Debug mode (Win32\Debug folder). So we can navigate to Win32 and Debug folder as below,

If you type dir command you will see all output files in Debug folder as in example below,

8. Now you can execute the executable *.exe file

How to compile and run a C program in the Terminal or command line with RAD Studio command prompt and compiler?

If you don’t want to use project settings and you just want to compile a *.c file you can use compilers listed in bin directory of C++ Builder or RAD Studio. For example for an 32bit Windows application you can use C++ Builder Compiler for Windows 32bit bcc32.exe as below,

or you can use bcc32c C++ Builder CLANG Compiler for Windows 32bit as below,

Note that when you compile a C file in this way, compiler will generate all exe and other output files to the same folder.

Don’t forget, you can also use Borland C++ Compiler and Dev-C++ to compile C programs. We highly recommend you use C++ Builder CE version that may allow you switch to the professional version easily.

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

For students, beginners, and startups you can download a free C++ Builder Community Edition. If you are a professional developer, you can download a free trial copy of Professional, Architect, or Enterprise versions of C++ Builder.

close

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

33+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux and some other operating systems. Dr. Yilmaz Yoru was born in 1974, Eskisehir-Turkey. He graduated from the department of Mechanical Engineering of Eskisehir Osmangazi University in 1997. One year later he started to work in the same university as an assistant. He received his MSc and PhD degrees from the same department of the same university. He has married and he is a father of a son. Some of his interests are Programming, Thermodynamics, Fluid Mechanics and Artificial Intelligence. He also likes the graphical 2D & 3D design and high-end innovations.
Related posts
C++Introduction to C++Learn C++

How To Exit A C Program In Power Shell

C++Introduction to C++Learn C++

How To End A C Program In An "If" Statement

C++Introduction to C++Learn C++

How To Stop A C Program In Terminal

C++Introduction to C++Language FeatureLearn C++

How to Run A C Program In The Linux Terminal