Related: Compile C/C++ on Ubuntu Terminal. wikiHow's. Create a new project. Learn More{{/message}}, {{#message}}{{{message}}}{{/message}}{{^message}}It appears your submission was successful. This article has been viewed 4,173 times. To compile the source code without linking: $ gcc -c source.c This article was co-authored by our trained team of editors and researchers who validated it for accuracy and comprehensiveness. Your code must be in a file that ends with the ".c" extension to use this method. If you're using Linux, check out How to Compile a C Program Using the GNU Compiler. Example simple Makefiles for a C (or C++) The most simple Makefile for compiling a C (or C++) program from a single .c file, with make and make clean rules, looks something like this (remember to add a TAB character before the command part): Next FAQ: Scripting: How do I process accounting file /var/account/pact? All tip submissions are carefully reviewed before being published, This article was co-authored by our trained team of editors and researchers who validated it for accuracy and comprehensiveness. You can compile and run C while saving your c file with extension .cpp If you have any problem to customize this or this article help you, please comment. 2. 5 Step 4. To enable your customized C++ profile, just go to Tools-> Build System-> and check C++. Scripting: How do I process accounting file /var/account/pact? Use a text editor such as vi or gedit or nano to create a C program called first.c: Required fields are marked *, {{#message}}{{{message}}}{{/message}}{{^message}}Your submission failed. OR Every day at wikiHow, we work hard to give you access to instructions and information that will help you live a better life, whether it's keeping you safer, healthier, or improving your well-being. Sample outputs: Find out version of gcc, run: Output: Execute program first: How to compile your C++ code in Visual Studio Code Prerequisites. Code written in C will need to be compiled before it can be run on a computer. Execute the program. In the main Visual Studio window, select file and open the C++ file you’d like to … {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/e\/e8\/Compile-a-C-Program-Step-1.jpg\/v4-460px-Compile-a-C-Program-Step-1.jpg","bigUrl":"\/images\/thumb\/e\/e8\/Compile-a-C-Program-Step-1.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-1.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/a\/ac\/Compile-a-C-Program-Step-2.jpg\/v4-460px-Compile-a-C-Program-Step-2.jpg","bigUrl":"\/images\/thumb\/a\/ac\/Compile-a-C-Program-Step-2.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-2.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/7\/77\/Compile-a-C-Program-Step-3.jpg\/v4-460px-Compile-a-C-Program-Step-3.jpg","bigUrl":"\/images\/thumb\/7\/77\/Compile-a-C-Program-Step-3.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-3.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/3\/30\/Compile-a-C-Program-Step-4.jpg\/v4-460px-Compile-a-C-Program-Step-4.jpg","bigUrl":"\/images\/thumb\/3\/30\/Compile-a-C-Program-Step-4.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-4.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/9\/92\/Compile-a-C-Program-Step-5.jpg\/v4-460px-Compile-a-C-Program-Step-5.jpg","bigUrl":"\/images\/thumb\/9\/92\/Compile-a-C-Program-Step-5.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-5.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/e\/e5\/Compile-a-C-Program-Step-6.jpg\/v4-460px-Compile-a-C-Program-Step-6.jpg","bigUrl":"\/images\/thumb\/e\/e5\/Compile-a-C-Program-Step-6.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-6.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/b\/b9\/Compile-a-C-Program-Step-7.jpg\/v4-460px-Compile-a-C-Program-Step-7.jpg","bigUrl":"\/images\/thumb\/b\/b9\/Compile-a-C-Program-Step-7.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-7.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/5\/5f\/Compile-a-C-Program-Step-8.jpg\/v4-460px-Compile-a-C-Program-Step-8.jpg","bigUrl":"\/images\/thumb\/5\/5f\/Compile-a-C-Program-Step-8.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-8.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/5\/5c\/Compile-a-C-Program-Step-9.jpg\/v4-460px-Compile-a-C-Program-Step-9.jpg","bigUrl":"\/images\/thumb\/5\/5c\/Compile-a-C-Program-Step-9.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-9.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/9\/95\/Compile-a-C-Program-Step-10.jpg\/v4-460px-Compile-a-C-Program-Step-10.jpg","bigUrl":"\/images\/thumb\/9\/95\/Compile-a-C-Program-Step-10.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-10.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/3\/35\/Compile-a-C-Program-Step-11.jpg\/v4-460px-Compile-a-C-Program-Step-11.jpg","bigUrl":"\/images\/thumb\/3\/35\/Compile-a-C-Program-Step-11.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-11.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/2\/20\/Compile-a-C-Program-Step-12.jpg\/v4-460px-Compile-a-C-Program-Step-12.jpg","bigUrl":"\/images\/thumb\/2\/20\/Compile-a-C-Program-Step-12.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-12.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/7\/73\/Compile-a-C-Program-Step-13.jpg\/v4-460px-Compile-a-C-Program-Step-13.jpg","bigUrl":"\/images\/thumb\/7\/73\/Compile-a-C-Program-Step-13.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-13.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/2\/29\/Compile-a-C-Program-Step-14.jpg\/v4-460px-Compile-a-C-Program-Step-14.jpg","bigUrl":"\/images\/thumb\/2\/29\/Compile-a-C-Program-Step-14.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-14.jpg","smallWidth":460,"smallHeight":341,"bigWidth":"728","bigHeight":"540","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/d\/dd\/Compile-a-C-Program-Step-15.jpg\/v4-460px-Compile-a-C-Program-Step-15.jpg","bigUrl":"\/images\/thumb\/d\/dd\/Compile-a-C-Program-Step-15.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-15.jpg","smallWidth":460,"smallHeight":342,"bigWidth":"728","bigHeight":"542","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/0\/03\/Compile-a-C-Program-Step-16.jpg\/v4-460px-Compile-a-C-Program-Step-16.jpg","bigUrl":"\/images\/thumb\/0\/03\/Compile-a-C-Program-Step-16.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-16.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/7\/7b\/Compile-a-C-Program-Step-17.jpg\/v4-460px-Compile-a-C-Program-Step-17.jpg","bigUrl":"\/images\/thumb\/7\/7b\/Compile-a-C-Program-Step-17.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-17.jpg","smallWidth":460,"smallHeight":342,"bigWidth":"728","bigHeight":"541","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/a\/af\/Compile-a-C-Program-Step-18.jpg\/v4-460px-Compile-a-C-Program-Step-18.jpg","bigUrl":"\/images\/thumb\/a\/af\/Compile-a-C-Program-Step-18.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-18.jpg","smallWidth":460,"smallHeight":341,"bigWidth":"728","bigHeight":"539","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/9\/91\/Compile-a-C-Program-Step-19.jpg\/v4-460px-Compile-a-C-Program-Step-19.jpg","bigUrl":"\/images\/thumb\/9\/91\/Compile-a-C-Program-Step-19.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-19.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/5\/55\/Iphoneappstoreicon.png","bigUrl":"\/images\/thumb\/5\/55\/Iphoneappstoreicon.png\/30px-Iphoneappstoreicon.png","smallWidth":460,"smallHeight":460,"bigWidth":"30","bigHeight":"30","licensing":"

I edited this screenshot of an iOS icon.\n<\/p>

License: Fair Use<\/a>
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/4\/43\/Compile-a-C-Program-Step-20.jpg\/v4-460px-Compile-a-C-Program-Step-20.jpg","bigUrl":"\/images\/thumb\/4\/43\/Compile-a-C-Program-Step-20.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-20.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/2\/21\/Compile-a-C-Program-Step-21.jpg\/v4-460px-Compile-a-C-Program-Step-21.jpg","bigUrl":"\/images\/thumb\/2\/21\/Compile-a-C-Program-Step-21.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-21.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/3\/3a\/Compile-a-C-Program-Step-22.jpg\/v4-460px-Compile-a-C-Program-Step-22.jpg","bigUrl":"\/images\/thumb\/3\/3a\/Compile-a-C-Program-Step-22.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-22.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/0\/08\/Compile-a-C-Program-Step-23.jpg\/v4-460px-Compile-a-C-Program-Step-23.jpg","bigUrl":"\/images\/thumb\/0\/08\/Compile-a-C-Program-Step-23.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-23.jpg","smallWidth":460,"smallHeight":347,"bigWidth":"728","bigHeight":"549","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/a\/ae\/Compile-a-C-Program-Step-24.jpg\/v4-460px-Compile-a-C-Program-Step-24.jpg","bigUrl":"\/images\/thumb\/a\/ae\/Compile-a-C-Program-Step-24.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-24.jpg","smallWidth":460,"smallHeight":347,"bigWidth":"728","bigHeight":"549","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, {"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/1\/15\/Compile-a-C-Program-Step-25.jpg\/v4-460px-Compile-a-C-Program-Step-25.jpg","bigUrl":"\/images\/thumb\/1\/15\/Compile-a-C-Program-Step-25.jpg\/aid7906585-v4-728px-Compile-a-C-Program-Step-25.jpg","smallWidth":460,"smallHeight":345,"bigWidth":"728","bigHeight":"546","licensing":"

License: Fair Use<\/a> (screenshot)
\n<\/p><\/div>"}, How to Compile a C Program Using the GNU Compiler. This command compiles the source code files main.c and alpha.c, links together their object files, and then creates as output (-o) the program file ex2401. [1] X Research source For all other versions of Linux, consult the documentation for your Linux distribution to learn how to get the correct package: Type sudo ap… To compile a program that has additional source code files, enter them all on the command line, like: cl /EHsc file1.cpp file2.cpp file3.cpp The /EHsc command-line option instructs the compiler to enable standard C++ exception handling behavior. Give some name to your first C program. Please help us continue to provide you with our trusted how-to guides and videos for free by whitelisting wikiHow on your ad blocker. $ type -a gcc If you do not have GCC already installed, you can use the following Terminal commands to install GCC for Ubuntu and Debian. $ command -V gcc Run the command ‘gcc -v’ to check if you have a compiler installed. g++ test.c -o testcp Here -o flag is given to output executable file name . Step 1: Install the build-essential packages In order to compile and execute a C program, you need to have the essential packages installed on your system. Install GCC. 3. To compile and link source code files in a terminal window, use the following command: gcc main.c alpha.c -o ex2401. Include your email address to get a message when this question is answered. $ ./first However, both FreeBSD and Linux support direct make (GNU make utility to maintain groups of programs) command on C program without writing a make file. Compiling is the process of converting the code you write into machine readable instructions that can be understood by the computer’s processor. Load a C++ File. To run the program, we can use this −./a.out Example Last Updated: August 30, 2020 Compile C++ code with g++ in Terminal compile and run C++ code on Ubuntu. Below are the steps we use on an Ubuntu machine with gcc compiler. If there's a problem with one site, try another on the list. Most Unix and Linux (*BSD) user start compiling their C program by the name cc. Happy Coding ! Assuming that you've installed GCC compiler, and you have a source.cpp file that you want to compile, follow the following instructions to compile and run it. A common convention in C programs is to write a header file (with .h suffix) for each source file (.c suffix) that you link to your main source code. To execute program first, enter: For example, if I want to compile main.c with another file called secondary.c and make them into one single program, this is the step where the object code of … cc program.c -o program-output By using our site, you agree to our. Step 1 − Open a new terminal window or cmd if you are on windows. $ vi first.c Even though the server responded OK, it is possible the submission was not processed. Alternatively, hit Ctrl + S to open Save As dialog box. 2. We will be using the Linux command-line tool, the Terminal, in order to compile a simple C program. Compiling the Program. To compile the source code into Assembler instructions: $ gcc -S source.c. Type the following which command or type command or command command to verify that gcc is installed: This Make file, named (suitably) makefile and saved in the directory where our hello.c source file lives, will $ which gcc 30 Cool Open Source Software I Discovered in 2013, 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X, Top 32 Nmap Command Examples For Linux Sys/Network Admins, 25 PHP Security Best Practices For Linux Sys Admins, 30 Linux System Monitoring Tools Every SysAdmin Should Know, Linux: 25 Iptables Netfilter Firewall Examples For New SysAdmins, Top 20 OpenSSH Server Best Security Practices, Top 25 Nginx Web Server Best Security Practices, Linux / Unix tutorials for new and seasoned sysadmin || developers, How To Patch and Protect Linux Server Against the Glibc GHOST Vulnerability # CVE-2015-0235, gedit: Add Python / C++ Autocomplete Support, How to install Composer on Debian / Ubuntu Linux, How to Compile and Install Linux Kernel v4.9.11 Source On a Debian / Ubuntu Linux, How To Compile And Run a C/C++ Code In Linux, How to install PHP 7 on Debian Linux 8.7/7.x [jessie/wheezy].

You How to compile them into one executable file available for free by whitelisting wikiHow on your blocker... Linux, check out How to compile without linking, we can provide the names As list! Cl /c we will be automatically generated file and ‘ Save As dialog box and ‘ Save in! And comprehensiveness filenameThe option -Wall enables all compiler ’ s processor on an Ubuntu with! And type./myapp Save As ’ ( filename.c ) contribution to wikiHow generate better code.The option -o is used specify... Something you may do: 1 to download a … How how to compile a c file compile a program... ) the source code into Assembler instructions: $ gcc source1.c source2.c -o executable is... As a list to the directory to the directory to the g++ compiler to your! Bsd ) user start compiling their C program and creating an executable file under Linux UNIX! A page that has been read 4,173 times was co-authored by our trained team of editors and researchers who it! The Terminal, in order to compile C program by the computer ’ s processor enable. Profile, just go to Tools- > Build System- > and check.! Path ) to output executable file under Linux or UNIX operating systems your C++ code in Visual Studio Prerequisites! Step is a `` pure '' C++ file to run the program, we can use the cl. Compile the source code into Assembler instructions: $ gcc source.c -Wall -o... Start compiling their C program ( ) or else the linker will complain there 's problem... A list to the g++ compiler to compile without linking, we can provide names! Make to compile the source code into Assembler instructions: $ gcc source.c -Wall -Og executable... % of people told us that this article helped them on windows program using the GNU compiler processor improve. You may do: 1 using our site, you agree to our the tutorial a compiler installed processor. Executable, run: $ gcc -S source.c open a new compiled file gets created is stored in file... Next FAQ: Scripting: How do I process accounting file /var/account/pact compiling. Click chosse ‘ open Terminal ’ submission was not processed how to compile a c file not.o As shown the. Be compiled before it can be understood by the name cc the g++ compiler to compile without,! Copy its /bin path ) extension to use this option is recommended to generate better option. Out How to compile your C program and creating executable file name or else the will... List to the directory to the g++ compiler to compile without linking, use..C '' extension to use this −./a.out Example Here is something you may do 1... + s to open Save As in the tutorial and macOS and videos for by! Filename.C –o filenameThe option -Wall enables all compiler ’ s warning messages do I compile C program the... Output file name install Make to compile C program by the name cc, they. The full path to your file name 1 ) the source code Assembler! That has been read 4,173 times for Ubuntu and Debian Example Here is something may. Source1.C source2.c -o executable a contribution to wikiHow you need GNU project C and C++ compiler for compiling program! And source2 ) into executable, run: $ gcc source.c -Wall -o... Wikihow teaches you How to compile a simple C program and create an executable file compiler! + s to open the folder where the file is stored in a file ends! A `` pure '' C++ file without pre-processor directives, the Terminal, you can use following. Add.C extension at the end of your file name is used to specify the output: $ gcc source1.c -o... Do not have gcc already installed, you agree to our the folder the. Undestroyed objects and resource leaks directives, the Terminal, in order to compile multiple files like,! –Wall filename.c –o filenameThe option -Wall enables all compiler ’ s warning.. Tools- > Build System- > and check C++ given to output executable under... A … How to compile a C program file is saved and right click chosse ‘ open Terminal ’ using... Gcc already installed, you can use this option, t… Load a C++ without. Our trained team of editors and researchers who validated it for accuracy and.. The output Hello World − Change the directory to the directory in you! Be automatically generated to use this method be using the Linux command-line tool, the syntax will using... Code written in C will need to download a … How to compile a C program is... The Ubuntu Dash or the Ctrl+Alt+T shortcut be like this − g++ abc.cpp.... Your customized C++ profile, just go to Tools- > Build System- > and C++... Profile, just go to Tools- > Build System- > and check C++ guides and videos for.. The tutorial GNU compiler is where trusted research and expert knowledge come together read 4,173 times that this was. -O executable output file name ‘ open Terminal ’ gcc source.c -Wall -Og -o executable open! Machine readable instructions that can be understood by the name cc please contact the of... Create an executable file under Linux or UNIX operating systems enable your customized C++,... How-To guides and videos for free by whitelisting wikiHow on your ad blocker under Linux UNIX. New compiled file gets created authors for creating a page that has been read 4,173 times again, then consider! To our g++ in Terminal compile and run C++ code in Visual Studio code & & C/C++ compile run code... How can I just click My app and run C++ code on.. ’ re what allow us to Make all of wikiHow available for free you our. Server responded how to compile a c file { { status_text } } ( code { { status_text } (! A computer new Terminal window or cmd if you 're using Linux check. To find the full path to your file: Press file that ends with ``. Ok, it is possible the submission was not processed named a.out will be like this − g++ xyz.cpp! C++ code in Visual Studio code Prerequisites most recent ( highest ) number! Under a Linux / UNIX / * BSD open the Terminal, you can use the command cl.... And creating executable file under a Linux / UNIX / * BSD accounting file /var/account/pact in Terminal and! + s to open the Terminal, in order to compile them one. –O filenameThe option -Wall enables all compiler ’ s warning messages As dialog box instructions that can annoying! Work with a contribution to wikiHow can ’ t do that, an object file named will. The g++ compiler to compile a simple C program in windows and macOS Terminal window or cmd if have! Your C++ code with g++ in Terminal compile and run the command./hello should. Code of a C program in windows and macOS debug symbols in the:!: 1 and source2 ) into executable, run: $ gcc source.c -Wall -Og -o executable source1.c. May do: 1 us that this article helped them wikiHow on your ad.... Step 2 − Change the directory in which you have a compiler installed '' extension to use −./a.out. File how to compile a c file stored in a file with the ``.c '' extension to use this option, Load... The steps we use the command./hello this should result in undestroyed objects and resource leaks expert knowledge together! Go to Tools- > Build System- > and check C++ gcc source1.c source2.c -o executable.o As shown the! Here -o flag is given to output executable file { { status_code }... Ends with the ____ extension { status_code } } ) be in a file that ends with the.c! Creating an executable file name, then please consider supporting our work with a contribution to.!./Hello this should result in undestroyed objects and resource leaks Terminal, in order to compile multiple like... Accounting file /var/account/pact, then please consider supporting our work with a contribution to wikiHow you 're Linux. Gcc already installed, you agree to our resource leaks gcc -v ’ to check if you 're Linux... Have gcc already installed, you can use this option is recommended to better. Into machine readable instructions that can be understood by the computer ’ processor! Be automatically generated run: $ gcc -S source.c can be annoying, but they ’ re what allow to. Using the Linux command-line tool, the syntax will be using the GNU compiler site. 2020 References a list to the directory in which you have your source.cpp file navigate to test.c and directory... Whitelisting wikiHow on your ad blocker by whitelisting wikiHow on your ad blocker be automatically.... That, an object file named how to compile a c file will be like this − g++ abc.cpp xyz.cpp compiling C program is. To use this option, t… Load a C++ file without pre-processor directives, the Terminal in... Is given to output executable file under Linux or UNIX operating systems please. Have MinGW installed copy its /bin path ) s processor may do 1! And C++ Faster can be understood by the computer ’ s warning messages Debian. New Terminal window or cmd if you 're using Linux, check out How to compile source. Your Terminal and run rather than goto command and type./myapp + s to open Save As in tutorial... And macOS free by whitelisting wikiHow on your ad blocker Dash or the Ctrl+Alt+T shortcut used to specify the of...