Developing On Windows

From Audacity Wiki
Revision as of 22:29, 3 December 2009 by Edgar (talk | contribs) (bump wxWidgets rev from 2.8.9 -> 2.8.10)
Jump to: navigation, search

Related pages:

It can help to work in stages. It's probably not advisable to try to do all the steps on this page in one session.

Visual Studio Express and Microsoft SDK

  • First get comfortable with Microsoft's free Visual Studio Express. The safest bet is the earlier version called MSVC++ Express 2005, downloadable from Microsoft here .
  • To develop in C/C++ for Windows you need a second download from Microsoft, the "Platform SDK", or if you are on Vista the new "Windows SDK". Download links:
Windows Server 2003 R2 Platform SDK for Windows 2000/XP/Server 2003:
ISO install 
Web Install 
Windows SDK for Windows Vista with .NET Framework 3 Runtime Components:

With MSVC set up you can write 'hello world' and similar small programs just to check things out, or use some of the examples that Microsoft provides. There is a Microsoft Forum for Visual Studio Express C++  where you can get help with the program if you need it.

There is a later Windows SDK for Windows Server 2008 and .NET Framework 3.5  which is only for Visual Studio 2008 and its free Express Editions . This SDK is compatible with Windows XP/Server 2003/Server 2008/Vista. There have in the past been reported problems with Visual C++ 2008 Express Edition converting the audacity.sln solution file when loading, though a recent report as of March 2008 did not encounter this issue.


Next get a recent version of wxWidgets. If you want to work with cutting edge code in Audacity, use wxWidgets 2.8.10. 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 is the DLL debug unicode version.

Set up for CVS

For Windows, TortoiseCVS from Sourceforge is the easiest. This adds extra menu items to the Explorer file manager. When you right-click over a folder you get additional items in the menu. These are used for synchronising your local copy of the files with the files at Sourceforge. Any user can read the files at Sourceforge via CVS, and that's all you need at this stage. If you have problems with accessing Audacity CVS from Windows send a message about it to the Audacity developer list by subscribing to the list here . If we can't help you sort it out then we can at least send you an up-to-date snapshot of the code which will get you started.

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

Compiling wxWidgets and Audacity: Current information

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 of 20 June 2008, there are now four configurations of Audacity, all modular. To build each, first build the appropriate configuration of Widgets for your required build of Audacity:

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

Building wxWidgets and setting the environment variable
  1. Open the ..\wxWidgets-2.8.9\build\msw\wx_dll.dsw file in Visual Studio. If you receive warnings that the project files must be converted to the current Visual C++ format, click "Yes To All".
  2. In "Solution Explorer" on the left, expand the "dbgrid" project, then expand "Setup Headers". Open both "setup.h" files and ensure that:
    1. #define wxUSE_ODBC is set to "1"
    2. #define wxUSE_ACCESSIBILITY is set to "1".
  3. In Build > Configuration Manager, or in the Configuation drop-down box, choose your configuration, for example DLL Debug or DLL Release.
  4. Click Build > Build Solution.
  5. Exit Visual Studio.
  6. Set the WXWIN evironment variable to "C:\wxWidgets-2.8.9" assuming you installed wxWidgets into its standard location of C:\. You can do this:
    • on Windows 98/ME, edit AUTOEXEC.BAT to add a line "set WXWIN=C:\wxWidgets-2.8.9" (without quotes). It's safest to do this by running MSCONFIG, and click "New" on the "Autoexec.bat" tab.
    • on Windows 2000 and later, click "System" in the Windows Control Panel, then in System Properties, click on "Advanced" then "Environment Variables". Add a user or system variable with name "WXWIN" and value "C:\wxWidgets-2.8.9" (again without quotes).
  7. On Windows 98/ME, reboot the computer. On later versions of Windows, simply restarting Visual Studio should normally pick up changes in environment variables.

Error: Unable to open winable.h?

If you get this error when compiling wxWidgets, open:
and comment out the line #include <winable.h> by adding // in front of it.

Other problems?

For more help if the build fails, see Troubleshooting building wxWidgets using Microsoft VC

Building Audacity should then be simple:

  1. Restart Visual Studio
  2. In the folder where you downloaded the Audacity source code, open ..\win\audacity.sln
  3. In the Configuration Manager, or configuration drop-down, choose the configuration, for example Debug or Release
  4. Click Build > Build Solution

Setup.h not found?

If when you try to compile Audacity you get errors about "Setup.h" not being found, that could mean:

a) You have not compiled wxWidgets in the right version for the version of Audacity you are trying to build (e.g. incorrect Unicode choice) OR
b) Your $(WXWIN) environment variable is wrong. For it to take effect after a change you must restart Visual Studio.

To run Audacity, you additionally need to copy files from your ..\wxWidgets-2.8.9\lib\vc_dll folder into the folder you run Audacity from. Copy these files for a Release build of Audacity:


For a Unicode Release build of Audacity, copy the same files which have an added "u" suffix, for example the first file above you need is "wxmsw28u_adv_vc_custom.dll". For a Debug build, copy the required files which add a "d" suffix, and for Unicode Debug, copy the required files with a "ud" suffix.

Alternatively, add "C:\wxWidgets-2.8.9\lib\vc_dll" (no quotes) to your existing "path" system variable, using AUTOEXEC.BAT or the Windows Control Panel. Note that the paths in the list of variables must be separated by semi-colons (;).

Common Compilation Errors

  • unistd.h not found
Add "..\..\lib-src\libsamplerate\Win32" to INCLUDE path (C/C++->General->Additional Include Directories) for the project that fails to build with this error (usually - libid3tag).
  • wx*26ud.lib not found when building in Unicode_Debug configuration
Change wx*26ud to wx*28ud for Audacity project (In Visual Studio: Project > Audacity Properties > expand Configuration Properties > Linker > Input > Additional Dependencies).
Make sure you built wxWidgets in Unicode Debug configuration.
This applies to all similar errors (with other configurations) - first check that dependencies has the right version, then check that these files exist at all.

Still got problems?
  • Try pasting the error messages into a Google search box. Many of the compiler and linker error messages are fairly cryptic unless you've seen them before, but there are often messages in web-searchable e-mail lists explaining what they mean and what to do.
  • For more help, see the file win/compile.txt in the Audacity source code. Failing all else, please contact us on the audacity-devel mailing list .