wiki:TutorialDir/Compile/Windows

Below is a list of steps to build PortAudio into a dll and lib file. The resulting dll contains all four current win32 PortAudio APIs: MME, DirectSound, WASAPI and ASIO.

PortAudio can be compiled using Visual C++ 2008 Express Edition which is available free from Microsoft. If you do not already have a C++ development environment, simply download and install.

1) PortAudio for Windows requires the files dsound.h and dsconf.h. Download and install the DirectX SDK from  http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba to obtain these files. If you installed the DirectX SDK then the DirectSound libraries and header files should be found automatically by Visual Studio/Visual C++. If you get an error saying dsound.h or dsconf.h is missing, you can declare these paths by hand. Alternatively, you can copy dsound.h and dsconf.h to portaudio\include. There should also be a file named dsound.lib in C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib.

2) For ASIO support, download the ASIO SDK from Steinberg at  http://www.steinberg.net/en/company/developer.html. The SDK is free but you will need to set up a developer account with Steinberg. Copy the entire ASIOSDK2 folder into src\hostapi\asio\. Rename it from ASIOSDK2 to ASIOSDK. To build without ASIO (or other host API) see the "Building without ASIO support" section below.

3) If you have Visual Studio 6.0, 7.0(VC.NET/2001) or 7.1(VC.2003), open portaudio.dsp and convert if needed.

4) If you have Visual Studio 2005 or Visual C++ 2008 Express Edition, double click the portaudio.sln file located in build\msvc\. Doing so will open Visual Studio or Visual C++. Click "Finish" if a wizard appears. The sln file contains four configurations: Win32 and Win64 in both Release and Debug variants.

For Visual Studio 2005 or Visual C++ 2008 Express Edition

5) Open Project -> portaudio Properties and select "Configuration Properties" in the tree view.

6) Select "all configurations" in the combo box above.

7) Now set a few options:

C/C++ -> Optimization -> Omit frame pointers = Yes

C/C++ -> Code Generation -> Struct member alignment = 4. This step should not be necessary but problems could arise if this value is other than 4.

C/C++ -> Code Generation -> Runtime library = /MT

Optional: C/C++ -> Code Generation -> Floating point model = fast

Click "Ok" when you have finished setting these parameters.

8) Select "Release" (instead of "Debug") in the main toolbar.

9) To suppress PortAudio runtime debug console output, go to Project -> Properties -> Configuration Properties -> C/C++ -> Preprocessor. In the field 'Preprocessor Definitions', find PA_ENABLE_DEBUG_OUTPUT and remove it. The console will not output debug messages.

10) From the Build menu click Build -> Build solution. For 32-bit compilations, the dll file created by this process (portaudio_x86.dll) can be found in the directory build\msvc\Win32\Release.

11) Now, any project which requires portaudio can be linked with portaudio_x86.lib (or _x64) and include the relevant headers (portaudio.h, and/or pa_asio.h , pa_x86_plain_converters.h) You may want to add/remove some DLL entry points. Right now those 6 entries are not from portaudio.h:

(from portaudio.def)

...
PaAsio_GetAvailableLatencyValues    @50
PaAsio_ShowControlPanel             @51
PaUtil_InitializeX86PlainConverters @52
PaAsio_GetInputChannelName          @53
PaAsio_GetOutputChannelName         @54
PaUtil_SetLogPrintFunction          @55

Building without ASIO support

To build PortAudio without ASIO support you need to:

1) Make sure your project doesn't try to build any ASIO SDK files. If you're using one of the shipped projects, remove the ASIO related files from the project.

2) Make sure your project doesn't try to build the PortAudio ASIO implementation files:

src\hostapi\pa_asio.cpp src\hostapi\iasiothiscallresolver.cpp

If you're using one of the shipped projects remove them from the project.

3) Define the PA_NO_ASIO preprocessor symbol in the project properties. In VS2005 this can be added under Project Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions. Defining PA_NO_ASIO stops src\os\win\pa_win_hostapis.c from trying to initialize the PA ASIO implementation.

4) Remove PaAsio_* entry points from portaudio.def

A similar procedure can be used to omit any of the other host APIs from the build. The relevant preprocessor symbols used by pa_win_hostapis.c are: PA_NO_WMME, PA_NO_DS, PA_NO_ASIO, PA_NO_WASAPI and PA_NO_WDMKS


David Viens, davidv@…

Updated by Chris on 7/11/2010

Back to the Tutorial