Difference between revisions of "Developing On Windows"

From Audacity Wiki
Jump to: navigation, search
(Updated download link for VS2013 Community Edition)
Line 5: Line 5:
* [[Developer Guide]]}}
* [[Developer Guide]]}}
{{advice|1='''Getting started building the current Audacity code:'''   
{{advice|1='''Getting started building the current Audacity code:'''   
* Audacity is currently built with Visual Studio 2013 C++ from http://www.visualstudio.com/downloads/download-visual-studio-vs. For free versions, use "Express 2013 for Desktop" or the full-featured Community edition (free for non-enterprise use). The necessary SDK is already included.
* Audacity is currently built with Visual Studio 2013 C++. You can obtain the full-featured Community 2013 edition (free for non-enterprise use) from http://download.microsoft.com/download/7/1/B/71BA74D8-B9A0-4E6C-9159-A8335D54437E/vs_community.exe. The necessary SDK is already included.
* Only wxWidgets 3.0.2 is now supported - obtain this from the top of http://wxwidgets.org/downloads/.     
* Only wxWidgets 3.0.2 is now supported - obtain this from the top of http://wxwidgets.org/downloads/.     
* Checkout the latest Audacity code from our GitHub repository at https://github.com/audacity/audacity/ (see [[GitHub]] for help).  
* Checkout the latest Audacity code from our GitHub repository at https://github.com/audacity/audacity/ (see [[GitHub]] for help).  

Revision as of 16:28, 6 June 2017

Gale 23Jan14: ToDo-1 Some removal of legacy historical context is needed here. Has been updated for move to VS2013 by means of advice div at top. This page needs more work or trimming just to the advice, probably.
This page gives some quick "Getting Started" help for building Audacity on Windows.
Related article(s):
Warning icon Getting started building the current Audacity code:

Common compilation errors

  • Setup.h not found
    If when you try to compile Audacity you get errors about "Setup.h" not being found, that could mean one of the following.
    • a) You have not compiled the correct version of wxWidgets for the configuration of Audacity you are trying to build. Build the "DLL Release" configuration of wxWidgets for a "Release" build of Audacity, or build the "DLL Debug" configuration of wxWidgets for a "Debug" build of Audacity.
    • b) Your $(WXWIN) environment variable is wrong. For it to take effect after a change you must restart Visual Studio or better, reboot.
    • c) Rarely, additional include directories need to be added to MSVC.
Still can't build?
Warning icon

The remaining instructions on this page are now legacy and only valid with Visual Studio 2008 and Audacity 2.1.1 or earlier.

Visual Studio Express and Microsoft SDK

Install Microsoft's Visual Studio or its free Visual C++ Express version. As of November 2013 Audacity only supports the 2008 version but there is an experimental 2012 project as well.

The VS 2008 downloads are old, so don't forget to do a Windows Update straight away for the latest available bug fixes.

To develop in C/C++ for Windows you need a second download from Microsoft:

  • Platform SDK for use on XP SP1/2 or
  • Windows SDK for use on Windows XP SP3, Vista, Windows 7, Windows 8, or Windows 10.

If you want to build Audacity with Windows DirectSound support as per official Audacity releases, install the

The installation will automatically define the DXSDK_DIR environment variable and its presence will cause DirectSound support to be automatically included when Audacity is built.

If you're an experienced developer you can probably now jump to http://audacity.googlecode.com/svn/audacity-src/trunk/win/compile.txt in the source code.

For everyone else, with VC++ set up you can write 'hello world' and similar small applications just to check things out, or use some of the examples that Microsoft provides. There is a Microsoft Forum for Visual C++ where you can get help with the application if you need it.

What about Visual Studio 2010? Or 64-bit?

It is strongly recommended that you use Visual Studio or VC++ Express 2008. The (free) VC++ 2008 Express version is just fine for building Audacity. The core developers have no intention of moving to VS2010 due to bugs in early VC++ 2010 Express versions that are not present in VC++ 2008 Express. If you're still keen to try:

  • As at April 2011, 3 projects in the solution will not build in VS 2010. wxWidgets steps must be followed closely and built targeting 32-bit, as must Audacity. Portaudio-v19, mod-script-pipe and of course Audacity will not build due to a number of MS compiler errors. Taglib would not build either, but is not currently in use in Audacity and no longer included in the solution file.
  • Several people have had a go at building Audacity with VS 2010.
    • Andreas Micheler has succeeded, after making some mods to the code.
    • Ed Musgrove has succeeded, also after various mods. See this Forum topic for details.
    If you are adventurous, you're encouraged to contact either person and post consolidated tips/experience here.

    It's a good idea to FIRST build with 2008 before attempting anything with 2010. Also check Bug 178 for the current known status of building in VS 2010.

  • VS 2010 apparently cannot build binaries that run on Windows XP RTM or Windows XP Service Pack 1. We still support those platforms. See this stackoverflow discussion.
  • Audacity is currently a 32-bit only application. It compiles fine on 64-bit versions of Windows using VS 2008, but is some way from being offered as a 64-bit application. A 32-bit limitation has been fixed for release in 2.0.6 that prevented loading projects where a clip contained 2^31 samples or more. However at least some other problems remain with such clips for example, incorrect display in Selection Toolbar.

    Making Audacity 64-bit ready requires a comprehensive review of Audacity, not just fixing the many errors flagged by the compiler. It's a large task, and not currently a priority.

Visual Studio 2012

There is some optimism about moving to Visual Studio 2012. Audacity already builds using Visual Studio Express 2012 and Widgets 2.8.12 as of November 2013, using win\audacity-vs2012_EXPERIMENTAL.sln in the Audacity sources.

To make wxWidgets build, it is necessary to remove the following lines from src\msw\windows.cpp in the current Widgets sources we use (as per this wxWidgets commit):

#if !defined __WXWINCE__ && !defined NEED_PBT_H
#include <pbt.h>

and then rebuild wxWidgets using VS2012.

"Update 1" for VS2012 in November 2012 reintroduced some support for builds that work on Windows XP but installation of VS2012 requires Windows 7, 8 or 10.

Ed Musgrove has made modifications to Audacity code to build it with VC++ 2012 Express and wxWidgets 3.0: http://forum.audacityteam.org/viewtopic.php?p=228591#p228591.

Download wxWidgets

If you're new to this, it can help to work in stages. It's probably not advisable to attempt all the remaining steps on this page in one session.

Get the 2.8.12 version of wxWidgets here: wxWidgets 2.8.12 (the version officially supported by Audacity as of November 2013). Follow the instructions in the wxWidgets documentation to get some of the wxWidgets samples to compile. For in-depth reference there is a 700-page book: Cross-Platform GUI Programming with wxWidgets which is also available as a PDF download. Time spent reading the documentation and trying things out is time well spent. There is one detail in setting up wxWidgets which is very important. It's setting up the $(WXWIN) environment variable. It's not set by the installer. It must be set correctly to your wxWidgets directory if you're to compile Audacity.

wxWidgets can be compiled in many different modes, such as Unicode and ANSI, debug and release, library or dll. If you want to work with the latest Audacity code, make sure that amongst the versions of wxWidgets that you compile are the DLL Unicode Debug and DLL Unicode Release configurations.

Don't try moving on further until you have at least one sample wxWidgets application compiled and running!

Set up for SVN

For Windows TortoiseSVN is possibly the easiest client to use to get the code from the Audacity repository. TortoiseSVN adds extra right-click menu items to the Explorer file manager which are used for synchronizing your local copy of the files with the repository. Any user can read the files and that's all you need at this stage.

Once TortoiseSVN is installed, using Explorer, create a folder for the Audacity source files, right-click on it and select 'SVN Checkout...' from the context menu to bring up the checkout dialog. Paste:


into the first text entry box (labeled "URL of repository:") and click the OK button. Wait a bit and you should have all the Audacity source files required (about 120 MB as of November 2013). The folder size expands to about 1.8 GB after compiling both Release and Debug solutions as of November 2013.

If you have problems checking out the code, please email our feedback address so we can look into it.

Compiling wxWidgets and Audacity

In May 2008 we made significant changes so that we build Audacity modularly. In the past, Audacity was always built against a custom monolithic non-DLL build of wxWidgets. This let us use multi-threaded wxWidgets while having Audacity as a single executable. But now we want to use plug-in modules in Audacity, and the modules and Audacity must both link to wxWidgets. Unfortunately it is not possible to embed the wxWidgets dll's into Audacity and share them as static links. So, Audacity will ship with these dll's and link to them dynamically. On the other hand, DLL builds of wxWidgets are automatically multi-threaded, so we no longer need a custom wxWidgets build.

As from 30 October 2013 ( r12804), there are just two configurations of Audacity, both modular, both for Unicode use only (Audacity stopped releasing ANSI builds for Windows 98 and ME with the 2.0.1 Release). To build, first build the appropriate configuration of Widgets for your required build of Audacity:

Audacity configuration Purpose Required wxWidgets build
Release General Unicode-based use DLL Unicode Release
Debug Slower performance, debuggable, Unicode support DLL Unicode Debug

Prior to r12804 an additional two configurations were available for non-Unicode use. These were called "Release" (requiring to build wxWidgets DLL Release) and "Debug" (requiring to build wxWidgets "DLL Debug"). The Unicode-based configurations at that time were explicitly called "Unicode Release" and "Unicode Debug" respectively.