# Using \`make\` to compile C programs (for non-C-programmers)

DevFeed: [Using \`make\` to compile C programs (for non-C-programmers)](<https://devfeed.tech/articles/using-make-to-compile-c-programs-for-non-c-programmers-21120.md>)

Original publisher: [Read original article](<https://jvns.ca/blog/2025/06/10/how-to-compile-a-c-program/>)

Author: Julia Evans

Published: 2025-06-10T00:00:00Z

Content type: tutorial

Language: en

Sources: [Julia Evans](<https://devfeed.tech/sources/julia-evans.md>)

Topics: [C](<https://devfeed.tech/topics/c.md>), [make](<https://devfeed.tech/topics/make.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Package manager](<https://devfeed.tech/topics/package-manager.md>), [gcc](<https://devfeed.tech/topics/gcc.md>), [apt](<https://devfeed.tech/topics/apt.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>)

Tags: [apt](<https://devfeed.tech/tags/apt.md>), [building](<https://devfeed.tech/tags/building.md>), [c](<https://devfeed.tech/tags/c.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [command-line](<https://devfeed.tech/tags/command-line.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [debian](<https://devfeed.tech/tags/debian.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [linux](<https://devfeed.tech/tags/linux.md>), [mac](<https://devfeed.tech/tags/mac.md>), [make](<https://devfeed.tech/tags/make.md>), [packages](<https://devfeed.tech/tags/packages.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

## AI overview

A beginner-oriented guide to compiling C programs from source, covering compiler installation, dependency discovery, and build tools on Ubuntu and macOS.

## Source excerpt

I have never been a C programmer but every so often I need to compile a C/C++ program from source. This has been kind of a struggle for me: for a long time, my approach was basically "install the dependencies, run make, if it doesn't work, either try to find a binary someone has compiled or give up". "Hope someone else has compiled it" worked pretty well when I was running Linux but since I've been using a Mac for the last couple of years I've been running into more situations where I have to actually compile programs myself. So let's talk about what you might have to do to compile a C program! I'll use a couple of examples of specific C programs I've compiled and talk about a few things that can go wrong. Here are three programs we'll be talking about compiling: paperjam sqlite qf (a pager you can run to quickly open files from a search with rg -n THING | qf) step 1: install a C compiler This is pretty simple: on an Ubuntu system if I don't already have a C compiler I'll install one with: sudo apt-get install build-essential This installs gcc, g++, and make. The situation on a Mac is more confusing but it's something like "install xcode command line tools". step 2: install the program's dependencies Unlike some newer programming languages, C doesn't have a dependency manager. So if a program has any dependencies, you need to hunt them down yourself. Thankfully because of this, C programmers usually keep their dependencies very minimal and often the dependencies will be available in whatever package manager you're using. There's almost always a section explaining how to get the dependencies in the README, for example in paperjam's README, it says: To compile PaperJam, you need the headers for the libqpdf and libpaper libraries (usually available as libqpdf-dev and libpaper-dev packages). You may need a2x (found in AsciiDoc) for building manual pages. So on a Debian-based system you can install the dependencies like this. sudo apt install -y libqpdf-dev libpaper-dev