You need to compile your program before you can run it. To do this, you'll need a C compiler, like gcc. You can install this with:

sudo apt-get install gcc

Then, to compile your program, creating an executable called file:

gcc -Wall -o file file.c

Which you should then be able to run:

./file
Answer from Jeremy Kerr on askubuntu.com
🌐
Jvns.ca
jvns.ca › blog › 2025 › 06 › 10 › how-to-compile-a-c-program
Using `make` to compile C programs (for non-C-programmers)
I sometimes write 5-line C programs with no dependencies, and I just learned that if I have a file called blah.c, I can just compile it like this without creating a Makefile: ... It gets automaticaly expanded to cc -o blah blah.c, which saves a bit of typing. I have no idea if I’m going to remember this (I might just keep typing gcc -o blah blah.c anyway) but it seems like a fun trick. If you’re having trouble building a C program, maybe other people had problems building it too! Every Linux distribution has build files for every package that they build, so even if you can’t install packages from that distribution directly, maybe you can get tips from that Linux distro for how to build the package.
🌐
Reddit
reddit.com › r/archlinux › compiling without gcc
r/archlinux on Reddit: Compiling without gcc
April 29, 2013 -

Hi r/archlinux, I just discovered Tiny C compiler (tcc), and after (finally) compiling cwm, I looked at the binary size : cwm w/ gcc : 336Kib cwm w/ tcc : 169Kib

So I wondered : "Can't I just use tcc instead of gcc for everything without pain ?". I think that the answer is... Hell no ! There are less compilation option, and each does not see the errors the same way... Example : void dat_func(int dat_arg) { return dat_arg; } gcc compile perfectly even with -Wall, but tcc throw an error.

So here is finally my question! Should file a bug report / submit a patch? Can an alternative compiler like tcc or clang integrates well in an archlinux system as a gcc replacement? Does anybody has experience with it? Does it REALLY worth it?

Discussions

What is the correct way to compile c code
gcc main.c path/to/cfiles/*.c -I path/to/headers -o main Note that that is a capital i before path/to/headers not lowercase L If everything is in the same directory just do: gcc ./*.c -o main More on reddit.com
🌐 r/cprogramming
17
6
June 2, 2023
How to run C program without having to run 'gcc filename.c' and 'a.exe ' - Stack Overflow
When i type the command gcc filename.c a new file 'a.exe' is created, then i have to run a.exe to get my program to run. Is there a way just to type one command to run my program or can you run a C More on stackoverflow.com
🌐 stackoverflow.com
What are the (common) ways of compiling a C program?
Overwhelmingly the answer is to use a build system, a task runner or configuration tool that will run the compiler and other build tooling for you (and many other things). The most common option of these is CMake, which commands about half of the C/C++ build system market. CMake itself is a meta-build system which will delegate to an underlying task runner like MSBuild, make, Ninja, or XCode. This process is mostly transparent to you as a user. All that said, it's a contentious issue online (offline people tend to have better things to talk about). You'll find many suggestions to use a specific task runners like make, people saying to directly run the build tools from the command line, people saying to just use a given IDE's tooling, etc. More on reddit.com
🌐 r/AskProgramming
26
14
August 18, 2024
How Do I Start Programming in C on a Linux Machine That Runs on Arch?
I use vim + gcc, I just go off of compiler errors and warnings that's usually enough for me More on reddit.com
🌐 r/C_Programming
53
0
November 8, 2024
People also ask

How Can You Suppress Specific Compiler Warnings in GCC?
A: Use the -Wno- flag to disable specific warnings, customizing the compiler's feedback during compilation.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › how to compile a c program in linux
How To Compile And Run a C Program In Linux | upGrad
What Is the Purpose of the -pthread Flag in GCC?
A: The -pthread flag enables multithreading with the POSIX threads library, linking and compiling thread-related functions.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › how to compile a c program in linux
How To Compile And Run a C Program In Linux | upGrad
What Does the -static Flag Do When Compiling a C Program?
A: The -static flag compiles the program with static linking, including all library dependencies within the executable.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › how to compile a c program in linux
How To Compile And Run a C Program In Linux | upGrad
🌐
CASS
cass-kul.github.io › tutorials › compiling-c
Compiling C | CASS
For Java and Python the compilation step is mostly hidden from the developer, and a simple command is enough to execute the code. Thus, to compile C programs, we need to install a set of tools (a compiler) that allows us to run the generated executable code. Below, we show you three options ...
🌐
VITUX
vitux.com › how-to-write-and-run-a-c-program-in-linux
How to Write and Run a C Program in Linux – VITUX
April 20, 2023 - This article taught you how to write, compile and run a simple C program in Linux.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › how to compile a c program in linux
How To Compile And Run a C Program In Linux | upGrad
August 29, 2025 - GCC (GNU Compiler Collection) is the most commonly used C compiler in Linux. Without it, you cannot compile C programs. Some Linux distributions come with GCC pre-installed, but you must verify it before proceeding.
Find elsewhere
🌐
Quora
quora.com › How-can-you-compile-a-C-program-without-having-to-use-a-specific-compiler-like-gcc
How to compile a C program without having to use a specific compiler (like gcc) - Quora
Answer (1 of 3): Pelles C is a fully Windows win32 compliant Compiler. Not only that but it will also print out your assembly code for you when tagged. In fact you can develop your own language using Pelle’s converted Assembly. Write a simple print function.
🌐
University of Chicago
classes.cs.uchicago.edu › archive › 2017 › winter › 51081-1 › LabFAQ › introlab › compile.html
Basic compiling on the Unix
To provide basic information on how to compile your C program on Unix. This page is intended for people who want to practice programming C now. This material will be greatly supplemented later in the course. ... gcc. This is a compiler from Gnu for Linux.
🌐
Reddit
reddit.com › r/cprogramming › what is the correct way to compile c code
r/cprogramming on Reddit: What is the correct way to compile c code
June 2, 2023 -

I've got a program that is split into header files and c files along with the main. I was told to do gcc main.c <library.c>... for every other code but i don't remember having to do that when I've done stuff with header files in the past. How are you supposed to do this. Also are you supposed to include the headerfile in the .c version that the header is declaring the functions from? Sorry for my lack of technical terms. I'm exhausted today

🌐
Stack Overflow
stackoverflow.com › questions › 74241939 › how-to-run-c-program-without-having-to-run-gcc-filename-c-and-a-exe
How to run C program without having to run 'gcc filename.c' and 'a.exe ' - Stack Overflow
So you can run gcc once, then run a.exe multiple times. You can name the executable something other than a.exe if you wish using the -o option: ... Sign up to request clarification or add additional context in comments.
🌐
Medium
medium.com › @filip.melka › your-first-c-program-on-linux-a-quick-guide-with-vim-and-vscodium-bc941228d4b2
Your First C Program on Linux: A Quick Guide with Vim and VSCodium. | by Filip Melka | Medium
November 17, 2024 - Just click the play button in the top-right corner to compile and execute your code without needing terminal commands. ... In this article, we covered the basics of writing, compiling, and running a C program on Linux using both Vim and VSCodium.
🌐
Reddit
reddit.com › r/c_programming › how do i start programming in c on a linux machine that runs on arch?
r/C_Programming on Reddit: How Do I Start Programming in C on a Linux Machine That Runs on Arch?
November 8, 2024 -

I’m looking to find an IDE that will work out all the configurations for me. Just looking for an IDE that will let me code, build, compile, and debug, without needing me to do some crazy JSON stuff that I honestly don’t understand at this moment. I find it much harder, personally, to set up development environments on a Linux machine in general but I am determined to learn how to turn one into a daily driver as I go through school for computer science. Any and all help is appreciated. Just need something that will still hold my hand a little as I learn more and more how to troubleshoot on my own. Thank you!

🌐
GeeksforGeeks
geeksforgeeks.org › c++ › how-to-compile-and-run-a-c-c-code-in-linux
How To Compile And Run a C/C++ Code In Linux - GeeksforGeeks
July 23, 2025 - We have written a simple C program to print the "welcome to geeks for geeks" message. Step 3: Now, save the file with the .c extension. So in this example, we have saved the file as welcome.c. Step 4: Now compile and run the C code in the terminal using the commands below. ... Our written code has been executed and the output is displayed in the above screenshot. We can also compile and execute the script using the GCC compiler.
🌐
Linux Questions
linuxquestions.org › questions › linux-software-2 › how-to-compile-gcc-if-you-don't-have-gcc-179515
How to compile GCC if you don't have GCC?
I was wondering the other day. How do you compile GCC if you don't have GCC and GCC is a dependency? And how did the first version of GCC get compiled?
🌐
Scaler
scaler.com › home › topics › how to compile c program in linux?
How to Compile C Program in Linux? - Scaler Topics
April 13, 2024 - Learn to install build-essential meta-package in Linux Operating System and compile and run a C program in the terminal on scaler topics.
Top answer
1 of 3
1

You first need to identify what part of your code is platform dependent and abstract them away the dependencies away. for example, you can using the factory pattern to invoke platform specific calls.

If you used VC 6, the code is likely MFC. You first step would be standardize the code, for example, rewrite code related to CArray with std::vector and CArchive with std::stream.

Back in the days I used the book Write Portable Code: A Guide to Developing Software for Multiple Platforms by Brian Hook for guidance. Now you should probably get yourself familiar with the modern C++ standard library first and take a look at QT.

2 of 3
0

Thank you reaching out!

 
I see you're trying to compile a C program that was developed using Microsoft Visual C/C++ 6.0 on a Linux system. While that specific version of MSVC is mainly for Windows, you can still achieve this task by following a few steps with the right tools and compilers on your Linux setup.

 Here’s a general approach you can take:

 1. Install GCC: Most Linux distributions come with the GNU Compiler Collection (GCC) pre-installed, but if it's not installed, you can do so by running:
sudo apt update
sudo apt install build-essential

 2. Modify Source Code: Since MSVC and GCC might use different headers or syntax, you might need to make some adjustments to the source code. For example, certain MSVC-specific functions or libraries may not be available in GCC. You might need to replace these with their POSIX equivalents.

 3. Compile the Code: To compile, you can use the following command:  
 gcc -o output_program your_program.c   

Here, output_program is the name of the compiled executable, and your_program.c is your source file.

 4. Run the Executable: After successful compilation, you can run your program
using:  ./output_program

 5. Debug as Necessary: If you encounter errors while compiling, pay attention to the error messages, as they often indicate necessary changes to the code.

 

 

 References: https://learn.microsoft.com/en-us/cpp/build/walkthrough-compile-a-c-program-on-the-command-line?vie…
https://learn.microsoft.com/en-us/cpp/build/projects-and-build-systems-cpp?view=msvc-170"
https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022

 

 

Let me know if you need any further help with this. I will be happy to assist.
If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.