PortAudio  2.0
PortAudio on Windows, OS X or Linux via. CMake

Building PortAudio stand-alone on Windows, OS X or Linux

CMake can be used to generate Visual Studio solutions on Windows, Makefiles (on Linux and OS X) and build metadata for other build systems for PortAudio. You should obtain a recent version of CMake from [http://www.cmake.org] if you do not have one already. If you are unfamiliar with CMake, this section will provide some information on using CMake to build PortAudio.

On Linux, CMake serves a very similar purpose to an autotools "configure" script - except it can generate build metadata apart from Makefiles. The equivalent of the following on POSIX'y systems:

build_path> {portaudio path}/configure --prefix=/install_location
build_path> make
build_path> make install

Would be:

build_path> cmake {portaudio path} -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/install_location
build_path> make
build_path> make install

The "-G" option specifies the type of build metadata which will be generated. You can obtain a list of supported build metadata formats by invoking (on any platform):

cmake -G

"make install" should install the same set of files that are installed using the usual configure script included with PortAudio along with a few extra files (similar to pkg-config metadata files) which make it easier for other CMake projects to use the installed libraries.

On Windows, you can use CMake to generate Visual Studio project files which can be used to create the PortAudio libraries. The following serves as an example (and should be done from a directory outside the PortAudio tree) which will create Visual Studio 2015 project files targetting a 64-bit build:

C:\PABUILD> cmake {portaudio path} -G "Visual Studio 14 2015 Win64"

After executing the above, you can either open the generated solution with Visual Studio or use CMake to invoke the build process. The following shows an example of how to build a release configuration (assuming the above command was executed previously in the same directory):

C:\PABUILD> cmake --build . --config Release

If you want ASIO support you need to obtain the ASIO2 SDK from Steinberg and place it according to Building Portaudio for Windows with ASIO support using MSVC. Both ASIO and the DirectX SDK are automatically searched for by the CMake script - if they are found, they will be enabled by default.

Using PortAudio in your CMake project

PortAudio defines the following CMake targets:

If you installed PortAudio as described above in Building PortAudio stand-alone on Windows, OS X or Linux and the install prefix you used (CMAKE_INSTALL_PREFIX) is in your system PATH or CMAKE_MODULE_PATH CMake variable, you should be able to use:


To define the "portaudio_static" and "portaudio" targets in your CMake project.

If you do not want to install portaudio into your system but would rather just have it get built as part of your own project (which may be particularly convenient on Windows), you may also use:

add_subdirectory("path to PortAudio location" "some binary directory" EXCLUDE_FROM_ALL)

EXCLUDE_FROM_ALL is not strictly necessary, but will ensure that targets which you don't use in your project won't get built.

Back to PortAudio Tutorials