-
Notifications
You must be signed in to change notification settings - Fork 358
InstallationMac
Note that CasADi is now available as binary installers for Mac, see the installation instructions. The instructions below apply to the installation of CasADi from sources.
Start out by installing all the dependencies using a package handler. We strongly recommend you to use Homebrew, as described below. There are also legacy instructions available on how to get the dependencies you need via Macports, but we don't recommend this option.
Homebrew is a package manager for Mac that greatly simplifies the installation of open source software. It is similar to Macports (below), but avoids many of its problems, e.g. by installing in a standard location (typically /usr/local) and by using the system compiler and system Python installation. Instructions:
- Install Homebrew as described on the website. At the end of installation, run
brew doctor
and resolve any issues appearing. - "Tap" homebrew science to be able to install packages such as cmake:
brew tap homebrew/science
- Brew at least the following:
brew install wget swig gcc cmake pkg-config
- Other useful development tools:
brew install valgrind gdb
- If gdb does not work out-of-the-box, you might need to "codesign" gdb as described in in e.g. appendix 1 of the GNAT User’s Guide (https://gcc.gnu.org/onlinedocs/gnat_ugn/Codesigning-the-Debugger.html#Codesigning-the-Debugger).
- Run
brew doctor
to make sure that your installation was successful and if there are some name conflicts that need to be resolved. - If you plan to use CasADi from Python (recommended), you need a Python environment with some standard numerical packages. For this you can either use the Python that is distributed with OS X or obtain a Python using homebrew. The Homebrew Python comes with the pip package manager, otherwise you have to install it separately. Use of other Python distributions (e.g. downloaded from the Python website) is strongly discouraged.
- Option 1 (Recommended but with a caveat): Use Python from Homebrew. This will guarantee a recent Python installation and comes with "pip". To install, simply do
brew install python
. The caveat is that you will have two Python installations on your system, since your Mac has Python pre-installed, and this can result in conflicts. Make sure that the Homebrew Python appears first in your paths. - Option 2 (Use system Python): Macs come with Python preinstalled, but it is unfortunately often not an up-to-date version with the latest bug fixes, hence the recommendation to use Homebrew Python above. It also does not come with "pip", so you will have to install that yourself, for example by issuing
easy_install pip
.
- Option 1 (Recommended but with a caveat): Use Python from Homebrew. This will guarantee a recent Python installation and comes with "pip". To install, simply do
- (Python) Obtain ipython (interactive Python shell) as well as the Python packages matplotlib, numpy and scipy from pip:
pip install ipython matplotlib numpy scipy
- To prepare CasADi for use from Matlab/Octave, seed the Matlab page.
One of the main benefits of using Python is the ability to work interactively. To do this efficiently, we recommend you to obtain an interactive Python environment such as the Ipython Notebook or Spyder. You will find the installation instructions below.
The Ipython Notebook gives a convenient way to interact with Python by writing notebooks, similar to what you may be used from e.g. Maple or Mathematica. You obtain it from pip:
pip install pyzmq jinja2 tornado ipython[notebook]
Spyder gives you a MATLAB-like development environment for Python. We recommend you to obtain it from pip and not download it from the Spyder website:
pip install sphinx spyder
If you try to launch Spyder (e.g. by issuing ´spyder´ from the command line), you will probably get an error message telling you to install PyQt4. This can be done as follows:
brew install pyqt
brew linkapps
Pay attention to the warning messages. You might need to modify your Python paths to get everything working.
IPOPT can either be obtained from a package manager, downloaded as a binary or compiled from sources. On OS X, we recommend you to obtain IPOPT from Homebrew:
-
brew install ipopt --with-openblas
(go for a long coffee break)
If you wish to build IPOPT from sources, just follow the instructions for Linux.
After IPOPT has been installed, you might want to install additional linear solvers. For more information on this, check IPOPT's webpage or the following instructions for obtaining HSL.
With the dependencies in place, compile CasADi from sources. We strongly recommend you to use clang/clang++ as the C/C++ compiler, which is the default compiler on newer OS X.
Go to some a directory of choice and checkout CasADi from Github. We recommend you to get the "master" branch, which contains the latest release (for information about other branches, see the installation instructions for Linux):
-
cd ~/src
(or any other directory where you want to keep your sources) git clone https://github.com/casadi/casadi.git -b master casadi
Configure and build. We recommend you to install everything locally, for example to $HOME/local
as follows:
cd casadi; mkdir build; cd build
cmake \
-D WITH_PYTHON=ON \
-D WITH_MATLAB=OFF \
-D CMAKE_INSTALL_PREFIX:PATH=~/local \
-D PYTHON_PREFIX:PATH=~/local \
-D PYTHON_LIBRARY:FILEPATH=`python-config --prefix`/lib/libpython2.7.dylib \
-D PYTHON_EXECUTABLE:FILEPATH=`python-config --prefix`/bin/python \
-D PYTHON_INCLUDE_DIR:PATH=`python-config --prefix`/include/python2.7 ..
Have a look at the generated CMakeCache.txt file. Make sure that the paths involving Python are consistent, in particular PYTHON_EXECUTABLE
, PYTHON_LIBRARY
and PYTHON_INCLUDE_DIR
. If you've installed locally, make sure that the libraries can be found by adding following lines (modify if your installation location was different from ~/local
) to your ~/.profile
or ~/.bash_profile
file:
export PYTHONPATH=$PYTHONPATH:$HOME/local
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/local/lib
Compile and run the test suite to make sure that the installation was successful:
make
make install
cd ../test/python
python alltests.py
Cf. also the installation instructions for Linux.