<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[onecolumn,letterpaper,11pt]{article}

%===================================================================
\input{common_latex/common_latex_packages}
\input{common_latex/common_latex_definitions}
\input{common_latex/common_latex_help_format}
%===================================================================

\begin{document}

\begin{labcover}
\labtitle{Help Topic: Installing and Using the MacPorts Package Manager}
\vspace{0.1in}
\labdate{Spring 2025}
\vspace{0.1in}
\labauth{Michael Benjamin, mikerb@mit.edu}
\labauth{Department of Mechanical Engineering}
\labauth{MIT, Cambridge MA 02139}
\labline
\end{labcover}

\wikidoc{file=Help.OSXMacPorts}
\wikidoc{auth=mikerb@mit.edu}

%====================================================================
\section*{Installing and Using the MacPorts Package Manager}
%====================================================================

We will use MacPorts or Homebrew occasionally in this class to install
open source software packages as needed. Both package managers work
perfectly fine for the purposes of 2.680. You do not need both package
managers. If you already have MacPorts installed, you can safely skip
installing Homebrew, and vice-versa.

\vspace{0.1in}
\noindent
Arguably there is greater adoption of Homebrew than MacPorts, and
Homebrew is generally faster to install packages, but both are very
fast in practice. If you would like to use Homebrew, see:

\vspace{0.1in}
\noindent
\urlx{https://oceanai.mit.edu/ivpman/help/osx_get_homebrew}

\vspace{0.1in}
\noindent
Here we discuss how to obtain MacPorts and install needed packages for
2.680.  If you're using a 2025 course-provided computer, Homebrew and
most of the common packages are already installed.

\vspace{0.1in}
\noindent
*Note: If you have a course computer, with MacPorts already installed,
you still need to augment your shell path as described later in this
section.

\vspace{0.1in}
\noindent
From the \urlx{http://www.macports.org} page: The MacPorts Project is an
open-source community initiative to design an easy-to-use system for
compiling, installing, and upgrading either command-line, X11 or Aqua
based open-source software on the Mac OS X operating system.

\vspace{0.2in}
\noindent
Note: You need to have installed XCode before MacPorts may be
installed. If you have not installed XCode yet, or if you are not
sure, return to this topic an do so. A direct link is here:

\vspace{0.1in}
\noindent
\urlx{http://oceanai.mit.edu/ivpman/help/osx_get_xcode}.

%--------------------------------------------------------------------
\subsection*{Getting the MacPorts base}
\label{sec_macport_pathb}

MacPorts is a package manager that allows you to easily download software
packages need in our labs. But package manager itself, the MacPorts base, 
first needs to downloaded and installed in the steps described here. 

\vspace{0.2in}
\noindent
(In most Linux distributions, the analagous package manager (apt-get) is 
present with the out-of-the-box OS installation. Perhaps because many 
Mac users are not developers, the steps of installing XCode and 
a package manager are left as options for developers.)

\vspace{0.2in}
\noindent
Here's how to get MacPorts:

\begin{packed_itemize}[3]
\item Get the MacPorts base here:
  \urlx{http://www.macports.org}. Click on the \var{DOWNLOAD} link and
  grab the .dmg disk image for whichever OS you may have.

\item Confirm that MacPorts is installed by typing "which port" and
  verifying that it returns \var{/opt/local/bin/port}. If not, see below
  on adding the MacPorts bin to your shell path.
  
\end{packed_itemize}

%--------------------------------------------------------------------
\subsection*{Add the MacPorts bin directory to your shell path}
\label{sec_macport_path}

MacPorts packages are installed in \var{/opt/local/}. The \cmd{port}
command line tool should be installed in \var{/opt/local/bin/}. You
need to add or ensure this latter directory to your shell path. If
you're not sure how to augment your shell path,
see 

\vspace{0.1in}
\noindent
\urlx{http://oceanai.mit.edu/ivpman/help/cmdline_augment_shell_path}.

%--------------------------------------------------------------------
\subsection*{Download packages needed for our labs}

Once the MacPorts base is installed, we need to use MacPorts package
manager to download and install common open source software packages
used in this course. This part is relatively easy and is all done from
the command line in a terminal window.  Again make sure the port
command is in your shell path and then:

\begin{consoleverb}
 $ sudo port install cmake
 $ sudo port install subversion
 $ sudo port install wget
 $ sudo port install libtiff
 $ sudo port install fltk-devel
\end{consoleverb}

\vspace{0.1in}

\begin{packed_itemize}[2]

\item Note: Not all of the above packages result in an executable,
  i.e., {\em program}, installed on your machine. Some do, like
  \cmd{cmake}, \cmd{wget}, and \cmd{svn} from the subversion
  package. The others install libraries that other programs need later
  in the course.

\item Hint: The \cmd{port install} command accepts a list of packages
  on the command line like the last entry above. This obviates the
  need for re-typing your password each time. 

\item Hint: The \cmd{port installed} command, with no arguments,
  returns a list of already installed packages. You may notice a
  number of packages installed that you didn't request. The MacPorts
  package manager will also down dependency packages as-needed, to build
  the ones you did explicitly request.

\item Hint: The \cmd{port installed requested} command, with no
  arguments, returns a list of installed packages that have been
  explicitly requested, as opposed to those that were installed
  because they were a dependency of a requested package.

\end{packed_itemize}

\end{document}

</pre></body></html>