Building Csound
Prev | Part I. Overview | Next

## Building Csound

Csound has become a complex project and can involve many dependencies. Unless you are a Csound developer or need to develop Csound plugins, you should try to use one of the precompiled distributions from http://www.sourceforge.net/projects/csound. However, building from source is probably the best option on GNU/Linux.

This section focuses on the main Csound 6 build system, which uses cmake, a cross-platform, open-source build system designed to build, test and package software.

When building Csound from source instead of using a precompiled package, you first need to obtain the sources for a release of Csound at http://www.sourceforge.net/projects/csound. The source packages have either a zip or tar.gz extension.

The latest (possibly unstable) Csound source code is also available through GIT. The Csound GIT front page is located at: http://csound.git.sourceforge.net/git/gitweb-index.cgi. Using git for just checking out and compiling is pretty easy. Install GIT for your platform and use this command to clone the Csound6 git repository:

    git clone git://git.code.sf.net/p/csound/csound6-git csound-csound6-git

This will checkout a read-only (meaning, you can not commit back to the central git repository) version of the Csound6 repo. To update with the latest from the master repo, use:

    git pull

The same process is used for the Csound manual. Use this command to clone:

    git clone git://git.code.sf.net/p/csound/manual6-git csound-manual6-git

## Basic requirements to build Csound 6 on any platform

- Install libdsndfile version 1.0.13 or later from www.mega-nerd.com/libsndfile.
- Install the Cmake build system from www.scons.org or from your system packages.

These are the minimum requirements for a build, but csound has many optional components which enhance functionality and add opcodes which may require additional libraries.

## Optional configurations (ALL platforms)

In most cases it is best to install the most recent stable versions of the optional libraries.

- Real-time audio can use the cross-platform PortAudio library (trunk version or devel-19 branch) from www.portaudio.com/usingcvs.html. Please note that stable version 18 will not work. Csound can also use several platform specific audio APIs like ALSA, JACK, CoreAudio and the Windows multimedia library, see each platform notes for details. On Windows, you can use the pre-built PortAudio from https://github.com/adfernandes/precompiled-portaudio-windows
- Real-time MIDI can use the cross-platform PortMidi library from www.cs.cmu.edu/~music/portmusic
- For GUI widgets, install FLTK 1.1 or 1.3 from www.fltk.org. You must configure and build FLTK with `--enable-shared --enable-threads`.
- For generating Python and Java interfaces, install the Software Interface and Wrapper Generator (SWIG) from http://www.swig.org.
- Install Python from www.python.org. In most cases it is best to install the most recent 2.7 version.
- CsoundAC requires FLTK and the boost C++ template libraries for random numbers and linear algebra, from http://www.boost.org. CsoundAC requires at least version 1.32.1.
- The fluid opcodes require the Fluidsynth library from http://savannah.nongnu.org/download/fluid.
- The OSC opcodes require the latest version of the liblo library from http://plugin.org.uk/liblo. On Windows, liblo requires a Windows version of the POSIX thread library (pthreads) which is available from http://sourceware.org/pthreads-win32; copy libpthreadGC2.a to libpthread.a. You may also need the latest version of autoconf from MinGW.
- The STK opcodes require STK source code from http://ccrma.stanford.edu/software/stk, copied into `csound6/Opcodes/stk`.
- The Loris opcodes requires Loris 1.8 to be installed: http://sourceforge.net/projects/loris/files. It will create the Csound Loris opcodes (along with Loris itself). When you run Csound use an additional command line flag: --opcode-lib. For example in Linux: --opcode-lib=/usr/local/lib/libloris.so

## Windows

The following is needed to build on Windows (more complete build instructions for Windows may be found in `How_to_Build_Csound_on_Windows.doc`):

- Install a compiler like gcc or Microsoft Visual Studio. If using MinGW (gcc), download the MinGW-build installer for 32-bit architecture, Posix threads, dwarf2 exception handling from http://sourceforge.net/projects/mingwbuilds/files/latest/download?source=files and run it. Install to a directory such as `D:/mingw32-4.8.1`.

  In addition to the compiler, building Csound and its dependencies requires some other tools. Install MSys from http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/msys%2B7za%2Bwget%2Bsvn%2Bgit%2Bmercurial%2Bcvs-rev13.7z/download. This includes bison, flex, autotools and some other goodies. Edit the MSys `etc/fstab` file to map the MinGW directory to `/mingw`.

  Options for the MinGW C compiler should be `-g -O2 -fopenmp -march=nocona -mstackrealign -DNDEBUG -I/usr/local/include`.

  Options for the MinGW C++ compiler should be `-g -O2 -std=gnu++11 -fopenmp -march=nocona -mstackrealign -DNDEBUG -I/usr/local/include`.

Optional configurations for Windows include the following:

- Real-time audio and MIDI can use the Windows multimedia library. This module will be built automatically if the headers are found.
- The VST Host opcodes require both the Steinberg VST headers.

## Linux

Optional configurations for Linux include the following:

- Real-time audio on Linux can use ALSA (www.alsa-project.org) and JACK (www.jackaudio.org/) in addition to PortAudio. Distributions usually provide the appropriate dev packages for these systems through their repositories.
- The DSSI Host opcodes require both the LADSPA and DSSI headers.

## Mac OS X

Optional configurations for Mac OS X include the following:

- Real-time audio can use CoreAudio (OSX builtin native audio system) and Jack, apart from PortAudio.
- The DSSI Host opcodes require both the LADSPA and DSSI headers.

## Building Csound 6 with CMake

When you have all the necessary packages and their sources (or -dev packages) to support your particular requirements on your hardware platform it is best to review the file

    Custom.cmake.ex

to discover the current configuration options. make any changes and place your customisations in

    Custom.cmake

Building is made considerably easier if, when installing, the downloaded headers and libraries are installed in their default locations. To modify the default build, in particular to handle non-standard options for third-party dependencies, such as where headers and libraries are to be found:

Avoid modifying the CMakeList.txt files.

With CMake it is usual to build in a difference directory to the sources. Create a directory for your build, change to that directory and run

    cmake
        path-to-source-directory

. All being well this will create Makefiles as necessary. You can then run "make" and "make install". If things go wrong it is sometime necessary to delete the file

    CMakeCache.txt

.

| Note
It is important that you set the environment variable `OPCODE6DIR` to the directory where plugin libraries are installed; in the case of a double precision build, `OPCODE6DIR64` should be set instead. Installers usually take care of this, but it is necessary when building from source so Csound can find its plugin libraries.

Prev | Up | Next
CsoundVST | Home | Csound Links