Apple macOS or OS X is a proprietary unix operating system, derived from the old BSD unix, and has all the requirements for CPL tools and programs to run natively on it. However the classical unix programming tools are not part of the base system, but they are offered by Apple as a separate Xcode
development environment. In addition CPL needs the gcc
compiler, and although Xcode includes a C compiler named gcc
, this is an Apple-modified version (also known as clang
) and lacks some necessary gcc extensions. Unmodified gcc
can be installed through a third-party package manager such as Homebrew. Hence come the following
terminalin the search box and click
terminal.app.
In a terminal execute the following click-to-copy line:
xcode-select --install
A dialog box will pop up asking if you want to install the Command Line Developer Tools. Accept. If the box does not appear, you probably have them already. Alternately you can install the full Xcode development environment from the App Store, but only do so if you want this much larger package for its own purposes.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew
up to date (the one just installed sometimes is not):brew update; brew upgrade
gcc
(the one provided by Apple is an alias for their own clang
):brew install gcc
CC
environment variable pointing at the brew-installed C compiler (currently named gcc-14
, but subject to change):curl -fsS -o /tmp/unpack-cpl.sh https://CPLcode.net/version-archive/unpack-cpl.sh && env CC=gcc-14 sh /tmp/unpack-cpl.shIf your gcc version is not gcc-14, please replace gcc-14 by your own version before executing the above line. Also be aware that the plain
gcc
command invokes the Apple-modified gcc (aka clang
) and not the Homebrew-installed one.
gnuplot
. You can do it via Homebrew:brew install gnuplot
or alternately find contributed macOS binaries on gnuplot's own website.
Use Option as Meta keybox in your Mac Terminal Keyboard preferences.
You are all set! Please notice that you may have to repeat steps 2 and 4 after a macOS version update. If you encounter problems, deleting the directory /Library/Developer/CommandLineTools
before repeating step 2 may help. Also notice that running a macOS-compiled CPL executable on bare macOS does not need any of the above procedure (save installing gnuplot if graphics are wanted). You only need to install gcc and the CPL tools when you want to edit, compile or interpret a CPL program, not to just run it.