-
Notifications
You must be signed in to change notification settings - Fork 312
Notes_about_building_PortAudio_with_MinGW
Most of the information about building PortAudio is in the official documentation. This page is a staging area while we work out how to document building with MinGW.
MinGW is a port of the gcc compiler toolchain to MS Windows. A related project is MSYS, which provides the Unix basic command line tools such as bash, ls, cp, etc. These are needed for running shell scripts. Note that the mingw project has now forked into two different projects (mingw and mingw-w64), the relevant differences are discussed later.
Compiling PortAudio with MinGW is supported. However you will need an installation of MinGW that has system header files for the host APIs that you want to target. As installed, MinGW can only build PortAudio targetting WMME and ASIO. Targeting DirectSound is possible. At the time of writing we're less sure about WASAPI and WD/MKS (see below for details). If you have trouble building PortAudio after reading this page, please let us know on the PortAudio mailing list and we'll try to help.
Before you can use the MinGW compiler you need to install it. You'll also need to install MSYS, which provides the command line environment for running ./configure and make.
MinGW recommends using their automated gui installer mingw-get-setup.exe . Check out the MinGW Getting Started page for details.
Once MinGW and MSYS are installed you need to run the command shell. You can do this by manually running bash from a Windows command prompt, or by setting up a shortcut or batch file to do the same. If you install the GUI version of MSYS you may even get a separate command shell GUI that you can run. (NOTE: If you installed the GUI version of MSYS, make sure you're running MSYS2 MinGW and not MSYS2 MSYS.) Whatever you do you need to make sure that you have the MSYS and MinGW tools in your path. One way to do this temporarily, at a Windows command prompt is the following:
First open a Windows command prompt, then (temporarily) add MinGW and MSYS binary directories to your path. (Important: MinGW recommends that you do not edit your global path). Note that I add the directories to the start of the search path here to avoid conflict with other commands in my path:
bc. C:\Users\Ross> set PATH=c:\MinGW\bin;c:\MinGW\msys\1.0\bin;%PATH%
Now you should be able to run bash (the MSYS shell):
bc. C:\Users\Ross> bash bash-3.1$
And gcc should be available:
bc. bash-3.1$ gcc --version gcc.exe (GCC) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
From that point you should be in a position to build PortAudio.
To build PortAudio from an MSYS shell prompt, change to the PortAudio directory and run ./configure and make (notice that the C: drive becomes /c/ in the MSYS path):
bc. bash-3.1$ cd /c/PortAudio/pa_stable_v19_20140121_rc/portaudio/ bash-3.1$ ./configure bash-3.1$ make
This will build the PortAudio library and all of the examples and tests into the bin directory.
Once make has finished you can run the examples, e.g.:
bc. bash-3.1$ bin/pa_devs
Will list the available devices, and
bc. bash-3.1$ bin/paex_sine
Should play a sine wave. There are a bunch of other examples.
By default ./configure will only build in support for the WMME audio API. This is a lowest common denominator audio API that is supported on all versions of Windows and can be reliably built with MinGW without any additional work. But with additional command line flags ./configure can try to build PortAudio with any of the supported host APIs. You can build a single PortAudio library that supports multiple native audio APIs.
You can get the full list of supported /configure parameters using the --help flag:
.bc $ ./configure --help
Of particular importance on Windows are the following options:
bc. --with-winapi Select Windows API support ([wmme|directx|asio|wasapi|wdmks][,...]) [wmme] --with-asiodir ASIO directory [/usr/local/asiosdk2] --with-dxdir DirectX directory [/usr/local/dx7sdk]
For example, to build PortAudio with support for WMME and DirectSound you could use the following ./configure command:
bc. $ ./configure --with-winapi=wmme,directx
Although that probably won't work because you need to have valid DirectX headers installed in /usr/local/dx7sdk, or somewhere else referenced by the --with-dxdir flag. This is discussed below.
NOTE: if you decide to reconfigure with different parameters, you should "make clean" prior to invoking "make".
To build PortAudio with DirectSound support you need a working set of DirectSound header files. MinGW does not ship with working DirectSound header files. Microsoft distribute these headers in the DirectX SDK, and more recently (since Windows 8) in the platform SDK. However the Microsoft headers probably won't work with MinGW. Furthermore, it is not so easy to find working header files. If you search the web you might get lucky, or you might find headers that do not work (e.g. the mingwdx headers didn't work for us).
As of this writing, the Allegro game programming library provide a set of DirectX headers that work:
http://alleg.sourceforge.net/files/dx9mgw.zip
Unzip them and then pass the path to ./configure using the --with-dxdir flag:
bc. $ ./configure --with-winapi=directx --with-dxdir=../dx9mgw
An alternative to finding some working DirectX headers is to use the mingw-w64 toolchain, which ships with working headers. See the section about mingw-w64 below.
To build PortAudio with ASIO support you need to get the ASIO SDK from Steinberg. It's a free download.
Then you need to pass the ASIO SDK directory to .configure, e.g.:
bc. $ ./configure --with-winapi=asio --with-asiodir=../ASIOSDK2.3
The MinGW distribution does not appear to ship with the correct headers for building WASAPI or WDM/KS. You might have better luck with MinGW-w64. Or you can go looking for a working header file set.
At least one developer used to compile PA/WASAPI with MinGW. We're not sure about WDM/KS.
MinGW-w64 is a fork of mingw that supports compiling both 32 bit and 64 bit applications. The mingw-w64 project has a different policy towards managing proprietary Microsoft header file issues, and ships with a more extensive set of header files sourced in-part from ReactOS and WINE (see http://sourceforge.net/apps/trac/mingw-w64/wiki/History for details).
MinGW-w64 can be used for building PortAudio with DirectSound support and may be useful for buidling WASAPI and WDM/KS support (untested at the time of writing).
The MinGW-w64 home page is here: http://mingw-w64.sourceforge.net/
You can get pre-built MinGW-w64 binaries from here: http://sourceforge.net/projects/mingwbuilds
On 31/01/2014, sqweek wrote:
I used mingw-builds-install.exe from http://sourceforge.net/projects/mingwbuilds to install the x64-4.8.1-posix-seh-rev5 build.
mingw-get-setup.exe from http://sourceforge.net/projects/mingw to install the CLI mingw-get tool, which I used to install the following:
bash bzip2 coreutils diffutils dos2unix file findutils gawk grep gzip less libbz2 libiconv libintl liblzma libmagic libminires libopenssl libregex libtermcap make mingwrt msysCORE openssh sed tar termcap texinfo w32api xz zlib
You probably get most of them from "mingw-get install msys-core", I don't remember which I installed explicitly.
Then I've just setup a shortcut to run "C:\Mingw\msys\1.0\bin\bash.exe -l", and made sure /c/Mingw/bin and /c/Mingw/builds/x64-4.8.1-posix-seh-rev5/mingw64/bin are in PATH.
I think that's it to get a windows environment where ./configure && make works.