### Introduction

Rsymphony is one of the solver packages supported by TestDesign. As of Rsymphony version 0.1.28, Mac users are likely to encounter error messages like below when the user tries to install the solver package from R.

* installing *source* package ‘Rsymphony’ ...
** package ‘Rsymphony’ successfully unpacked and MD5 sums checked
** using staged installation
Cannot find SYMPHONY libraries and headers.
See <https://projects.coin-or.org/SYMPHONY>.
ERROR: configuration failed for package ‘Rsymphony’

This document describes a potential fix to this problem. An admin account is required.

### Install SYMPHONY libraries

The cause of the error is that Rsymphony requires SYMPHONY libraries, but the libraries are not installed. The goal of this section is to install the libraries.

Step 1. Open the terminal from Launchpad. Switch to the admin account on your system by running the following line in terminal prompt. Make sure to replace username with the actual username of the admin account. Type in the account password once prompted.

su username

Step 2. Install the homebrew package manager by following the instructions on http://brew.sh/. The purpose of this step is to allow installing SYMPHONY with it.

Step 3. Install SYMPHONY by running the following lines in terminal.

brew tap coin-or-tools/coinor
brew install symphony
brew install pkg-config

Rsymphony solver package should now be able to locate the SYMPHONY libraries. Retry installing the Rsymphony solver package in R.

If the install fails, proceed to the next step.

### Modify the Rsymphony solver package to manually point to SYMPHONY libraries

Step 1. Install wget by running the following line in terminal. The purpose of this step is to allow downloading the package file directly from CRAN servers.

brew install wget

Step 2. Run the following lines in terminal to download the Rsymphony solver package. The first line downloads the package file, and the second line unpacks the file.

sudo wget https://cran.revolutionanalytics.com/src/contrib/Rsymphony_0.1-28.tar.gz
sudo tar -xzvf Rsymphony_0.1-28.tar.gz

Step 3. Open the Rsymphony folder with running the following line. This will open a window. Leave the Terminal open as it will be used in later steps.

open ./Rsymphony

Step 4. Open the file configure with a text editor software. Comment out the lines 51-55 by inserting #s at the beginning of each line as below. Save it as the same file.

#if test \${status} -ne 0; then
# echo "Cannot find SYMPHONY libraries and headers."
# echo "See https://projects.coin-or.org/SYMPHONY."
# exit 1
#fi

Step 5. Open the src folder and open R_symphony.cc file. Change line 12 #include <coin/symphony.h> to:

#include <symphony.h>

Step 6. Run the following line in terminal to install the modified Rsymphony package.

sudo R CMD install Rsymphony

This will make the Rsymphony solver package available in R.

If the R CMD fails with --lgfortran error, proceed to the next step.

### Tell R where Fortran libraries are located

The cause of the error is that R needs Fortran libraries to build the package, but it does not know where they are. They are already available on your system: when you installed the SYMPHONY libraries from the previous steps, it installed gcc library as a requirement, which contains Fortran libraries as well.

Step 1. Run the following lines in terminal. This points R to the Fortran libraries.

mkdir ~/.R
cat << EOF >> ~/.R/Makevars
FLIBS = -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
EOF

Step 2. Run the following line in terminal to install the modified Rsymphony package.

sudo R CMD install Rsymphony