Image for post
Image for post

Getting Compilers

In my youth, a seasoned Linux guru commented how any new computer without a compiler, is not a computer. As my knowledge grew, and given the popularity in open source, this made sense. Often, I am required use compilers when installing tools or libraries needed for popular platforms like Ruby, Python, and Node.js.

Compiler Overview for the Uninitiated

So what is a compiler anyway, and why do you need it?

And Why?

These days, many open source tools and applications, and well, just cool stuff, requires compilers. If you work in operations, development, quality assurance, and other roles, you simply cannot avoid need to use compilers.

macOS

Apple goes out of their way to push you toward using Apple Store to download their graphical IDE, but you really don’t need to get that. For most cases, all you need is to get the command line tools.

Installing Command Line Tools

For that, you can get the tools by running this:

xcode-select --install
# Mojave only - need headers or nothing works
TOOLS_PATH="/Library/Developer/CommandLineTools/"
HEADERS_PKG="macOS_SDK_headers_for_macOS_10.14.pkg"
sudo installer -pkg $TOOLS_PATH/Packages/$HEADERS_PKG -target /

Installing Homebrew

Once you have command line tools with both compilers and the headers that compilers need, you may want to install some packages with Homebrew.

PREFIX="https://raw.githubusercontent.com"
SCRIPT_PATH="Homebrew/install/master/install"
ruby -e "$(curl -fsSL $PREFIX/$SCRIPT_PATH)"

XCode

You can download Apple’s graphical IDE, XCode, either from Apple Store, or directly from https://developer.apple.com.

Windows

On Windows, in order to get command line compiler tools, you need to install a full IDE called Visual Studio. The free community edition is fine. This program requires installation of .Net Framework 4.5.1 (or better, a more recent 4.x version).

Installing Chocolatey

Once you have Chocolatey installed, you can install compilers and other packages available in the public domain for Windows. In PowerShell in Administrator mode.

Set-ExecutionPolicy Bypass -Scope Process -Force; 
$script_url = 'https://chocolatey.org/install.ps1'
iex ((New-Object System.Net.WebClient).DownloadString($script_url))

Installing Compilers

With Chocolatey, you can compilers and dependencies by running this in Powershell in Administrator mode:

choco install -y microsoft-build-tools
refreshenv

Linux

Linux, as you can imagine, is straightforward.

Ubuntu 16.04

This works on Debian family of distributions, like current versions Ubuntu, Mint, and Debian.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y build-essential

CentOS 7

This works on RHEL based distributions like CentOS and Amazon Linux. It should work on Fedora as well.

sudo yum -y update
sudo yum
group install "Development Tools"

Wrapping Up

When writing tutorials, I found myself re-documenting how to get core essential tools like compilers, and so I wanted to get this out there, and just reference this common blog.

Written by

Linux NinjaPants Automation Engineering Mutant — exploring DevOps, Kubernetes, CNI, IAC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store