1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00
audacity/win/compile.txt
windinthew a106ae232f * Correct "Compling Audacity" typo passed through from e-mail to "Compiling Audacity", plus move down "Developing in Windows" link to help people check for common compilation errors
* Errors and inaccuracies are better directed to feedback@ so there is no disincentive effect of having to register on the Forum to report obvious errors
2010-09-10 12:09:15 +00:00

668 lines
28 KiB
Plaintext

Compiling Audacity(R) for Microsoft Windows(TM)
copyright (c) 1999-2010 Audacity Team
Authors:
Asger Ottar Alstrup
Vince Busam
Dave Fancella
Vaughan Johnson
Steve Jolly
Leland Lucius
Markus Meyer
Shane Mueller
Lynn Allan
Martyn Shaw
========================================================================
This version is currently accurate for Audacity version 1.3.13.
If you find the advice here inaccurate or incomplete, please
e-mail feedback@audacityteam.org .
========================================================================
Audacity releases are now built with Microsoft Visual C++ 9
(a.k.a Visual C++ 2008) generically known as "VC9".
For instructions on compiling Audacity under the Cygwin
UNIX Emulation Layer, see the "Compiling Audacity under
Cygwin" section below. This is not maintained.
Note that Audacity uses VC++'s multithreaded DLL runtime libraries.
If you have MSVC installed, these are in your PATH, but users to
whom you distribute your builds may not have them, so you may have
to distribute them, as described for the wxWidgets DLLs, below.
---------------------------
MSVC++ STEP 1: Download wxWidgets
---------------------------
To simplify the implementation of a near-identical user
interface across platforms, Audacity uses classes and
resources from wxWidgets, a portable GUI framework for C++
(and Python). You must download and build wxWidgets before
attempting to compile Audacity, or nothing will work!
wxWidgets is available at "http://www.wxwidgets.org/".
Audacity 1.3.13 requires wxWidgets 2.8.11.
To build on Windows only, download the wxMSW package
(installer or zip).
------------------------
MSVC++ STEP 2: Build wxWidgets
------------------------
When you have downloaded and installed wxWidgets, you must
build it.
For wxWidgets' instructions on compilation
(and details about static versus dll linkage), see
"C:\wxWidgets-2.8.11\docs\msw\install.txt".
Note therein that wx_dll.dsw adds the dependencies to
force the correct build order for DLLs, which wx.dsw
does not. Because of this, wx_dll.dsw doesn't work for
static libraries.
1. Open "C:\wxWidgets-2.8.11\build\msw\wx_dll.dsw" with
Visual Studio 2008 (for VC9).
Make sure to use wx_dll.dsw, not wx.dsw, because wx.dsw
does not have the correct dependencies for the DLL builds.
When you open wx_dll.dsw, Visual Studio will prompt whether
to convert. Click "Yes To All". Next time you open a Visual
Studio session, you can avoid this prompt by opening
"C\wxWidgets-2.8.11\build\msw\wx_dll.sln" instead of wx_dll.dsw.
2. If you want to use the accessibility features, we have modified a
couple of the wxWidgets files. Rather than provide a patch, we
store the modified files in SVN, and you can replace the
corresponding wxWidgets files.
In "audacity\win\wxWidgets_additions" are one .cpp and one .h file.
You may want to make backups of the wxWidgets originals of these,
in case you also build without these accessibility features.
* Copy access.cpp to "C:\wxWidgets-2.8.11\src\msw\ole\".
* Copy setup.h to "C:\wxWidgets-2.8.11\include\wx\msw\".
Audacity releases are built with these accessibility features.
3. Build wxWidgets for all configurations of Audacity that you want.
* Build "DLL Release" to use in a "Release" version of Audacity.
* Build "DLL Unicode Release" to use in a "Unicode Release"
version of Audacity.
* Build "DLL Debug" to use in a "Debug" version of Audacity.
* Build "DLL Unicode Debug" to use in a "Unicode Debug"
version of Audacity.
See "MSVC++ STEP 5: Build Audacity" for the differences
between these versions of Audacity.
If you use "Batch Build" under the "Build" menu, you need select
only the following five projects to build (not the whole solution)
for each configuration:
* adv
* base
* core
* html
* net
Because of dependencies, this should also build these projects:
* wxexpat
* wxjpeg
* wxpng
* wxregex
* wxtiff
* wxzlib
If you build the whole solution, ignore the linker errors for
wxbase28*_odbc*.* dbgrid.
4. Proceed with the rest of the process for building Audacity.
You will see the instructions for how to copy the appropriate
wxWidgets DLL's in the section "MSVC++ STEP 5: Build Audacity"
at the step "Provide access to the wxWidgets DLLs".
--------------------------
MSVC++ STEP 3: Download Audacity
--------------------------
Now you can compile Audacity. To check out the latest
source code from SVN, see the instructions at
"http://audacity.sourceforge.net/community/developers".
--------------------------------------------
MSVC++ STEP 4: Set wxWidgets location for Audacity
--------------------------------------------
Before you can start the build process, you must update the
project settings to tell Visual C++ where to find wxWidgets.
There are three settings that need changing:
1. Include Directory (e.g., "C:\wxWidgets-2.8.11\include")
2. Resource Directory (e.g., "C:\wxWidgets-2.8.11\include")
3. Library Directory (e.g., "C:\wxWidgets-2.8.11\lib")
Fortunately, this is parameterized, using a Windows system
environment variable. There are various ways to set these, so
look in the Windows help system. You want to create an
environment variable WXWIN, set to the top-level directory
where you installed wxWidgets. For example,
in your "autoexec.bat" file, you might have a line:
set WXWIN=C:\wxWidgets-2.8.11
Note that you don't want a trailing backslash on that.
On newer version of Windows, the settings for environment
variables can be found in the system control panel. Click
the "System" option, then the "Extended" or "Advanced" tab,
then "Environment variables".
In the Audacity project file, there are declarations like
$(WXWIN)\include
that get interpreted as, e.g., "C:\wxWidgets-2.8.11\include".
Once you have set the WXWIN environment variable correctly,
the Audacity project file's declarations will do the rest.
Note that you have at least to restart the IDE so it picks up
changes in the environment variables. It is safer to reboot
the computer to ensure the variables are read correctly.
-----------------------
MSVC++ STEP 5: Build Audacity
-----------------------
Run Visual C++ and load the Audacity solution,
"audacity\win\audacity.sln".
Optional Features
1. Locally installed help is optional, but required for a full release
build (the "help" folder is included in the installer, but removed from
the zip distribution). The Python library is required, obtainable from
http://www.python.org/download/ . Add the location of the top-level
directory where you installed Python to your Path environment
variable. For help with environment variables, see MSVC++ STEP 4 above.
Build the "help" project by enabling it in the MSVC++ Configuration
Manager. This will download a copy of the Manual wiki onto your machine
and copy it to the correct place for your build. If the local copy needs
updating at any time, run audacity\scripts\mw2html_audacity\wiki2htm.bat
and re-build the "help" project.
2. To support languages other than English in your build of Audacity,
you must enable and build the optional "locale" project. This is
required for a full release. You will need to obtain msgfmt.exe from
http://audacity.sourceforge.net/files/msgfmt.zip. Add the location of
the directory containing msgfmt.exe to your Path environment variable.
3. Some functionality in Audacity is currently turned on its default
configuration, but requires that extra libraries be downloaded
separately to use it.
* To allow export of MP3 files, download LAME:
http://manual.audacityteam.org/index.php?title=FAQ:Installation_and_Plug-Ins#lame
* To allow import and export of a much wider range of audio formats
(including WMA, M4A and AC3), and to import audio from video files,
download FFmpeg:
http://www.audacityteam.org/manual/index.php?title=FAQ:Installation_and_Plug-Ins#installffmpeg
To change the libraries that are enabled in Audacity, open the file
"win\configwin.h" and comment or uncomment the libraries as required.
4. DirectSound (Microsoft) and ASIO (Steinberg) are sound card interface
protocols that are more efficient than the standard WMME. Unlike WMME,
not all sound card drivers support them.
TO ADD SUPPORT FOR DIRECTSOUND:
Install the DirectX SDK from Microsoft (http://msdn.microsoft.com/directx).
The installation will automatically define the DXSDK_DIR
environment variable and its presense will cause DirectSound
support to be automatically included when Audacity is built.
Audacity releases from 1.3.7 onwards include DirectSound support.
TO ADD SUPPORT FOR ASIO:
Because ASIO is a PROPRIETARY, closed standard,
we (or any third party) cannot distribute its SDK.
That means we cannot distribute builds of Audacity that support
ASIO, because Audacity is licensed under the
GPL (http://audacity.sourceforge.net/about/license), which requires
we distribute all source code.
So, although you can build your own copies of Audacity with
ASIO support, for personal use, you cannot distribute them without
violating the Audacity license and the ASIO license.
If you build ASIO support into Audacity, do not distribute that build.
If you wish ASIO support, install the ASIO SDK from Steinberg
(http://www.steinberg.net ... select Company, then 3rd Party
Developers), then define an environment variable called
ASIOSDK_DIR, as you did for WXWIN, above. The value should be
the full path to the base directory of the ASIO SDK, e.g.,
set ASIOSDK_DIR=C:\ASIOSDK2
Build Audacity
Select the configuration that you wish to build:
* "Release" for general use
* "Unicode Release" for Unicode-based, general use
* "Debug" for a slower but debuggable executable
* "Unicode Debug" for a Unicode-based, slower, debuggable
executable
You can select the configuration from the Solution
Configurations pull-down menu, or select it from the "Build"
menu > "Configuration Manager..." dialog box.
Build Audacity by giving the "Build" menu > "Rebuild Solution"
command.
Provide access to the wxWidgets DLLs
Each Audacity executable needs access to five specific wxWidgets
DLLs from those you built in "MSVC++ STEP 2: Build wxWidgets"
above. You can copy them to your Windows PATH, or more simply,
to the same directory as the executable. If you are building
Audacity for public release using the *.iss installer script,
you must copy them to the executable directory. The DLLs required
are at "C:\wxWidgets-2.8.11\lib\vc_dll":
wxbase28*_net_vc_custom.dll
wxbase28*_vc_custom.dll
wxmsw28*_adv_vc_custom.dll
wxmsw28*_core_vc_custom.dll
wxmsw28*_html_vc_custom.dll
The "*" in the file names above is replaced in the actual files by
a suffix specific to its Widgets configuration. You can identify the
DLLs needed for each Audacity version as follows:
"" (no suffix) for "Release" versions
"u" for "Unicode Release" versions
"d" for "Debug" versions
"ud" for "Unicode Debug" versions
So for instance, a Unicode Debug version of Audacity should have:
wxbase28ud_net_vc_custom.dll
wxbase28ud_vc_custom.dll
wxmsw28ud_adv_vc_custom.dll
wxmsw28ud_core_vc_custom.dll
wxmsw28ud_html_vc_custom.dll
in the "audacity\win\unicode debug" directory.
If this procedure doesn't work, check the "Common Compilation
Errors" section on
http://audacityteam.org/wiki/index.php?title=Developing_On_Windows .
If you still need help after that, please ask on the "Compiling
Audacity" board at http://forum.audacityteam.org/. However, the first
suggestion there is likely to be "try it again with a clean
installation of the wxWidgets source and the latest Audacity source
from SVN". So if that's not what you attempted, please try that first.
---------------------------
HELP! I get linker errors!
---------------------------
In some cases, Audacity does compile, but during the linking
process you get a bunch of error messages like this:
LIBCMTD.lib(LIBCMTD.dll) : error LNK2005: _free
already defined in MSVCRTD.lib(dbgheap.obj)
This is usually caused by conflicting runtime library settings.
Audacity is now linked with DLL linkage.
In VC9, select the Audacity project. Then
Project > Properties > C/C++ > Code Generation > Runtime Library
should be
"Multi-threaded Debug DLL (/MDd)" for Debug or Unicode Debug builds,
or
"Multi-threaded DLL (/MD)" for Release or Unicode Release builds.
Make sure you set the correct library type for all corresponding build
configurations.
Also make sure you check all other libraries, like the Ogg Vorbis
libraries, if you have them installed.
You may want to use the /VERBOSE:LIB linker parameter to
get information about which library is causing the conflict.
If all else fails, use the following procedure to force
Audacity to link to the correct library:
Select the Audacity project in Solution Explorer.
Then choose Project > Properties.
Select the desired configuration (e.g., "Debug" or "Release").
Select the "Linker" folder in the tree on the left, and the
"Input" item. In the "Ignore Specific Library" field, enter
"msvcrt.lib" if you were attempting to perform a
Release build, or "msvcrtd.lib" for a Debug build.
On some systems, you will need to ignore "libcmt.lib"
or "libcmtd.lib" instead of "msvcrt.lib" or "msvcrtd.lib",
depending on the library which actually causes the conflict.
Note that if you have configured all libraries correctly,
none of the above should actually be necessary.
========================================================================
-------------------------------
Compiling Audacity under Cygwin
-------------------------------
Compiling Audacity under Cygwin is considered "experimental"
at this time, and you may notice a few problems when you do so.
Please be patient, and make sure to submit bug reports to the
development team. If you follow these instructions closely, you
*should* be able to build Audacity.
These instructions will attempt to help you to compile using
the experimental additions that appeared sometime around the 1.2
release. They will also attempt to help you to compile Audacity
yourself without the aforementioned support. Make sure to read
the instructions in their entirety before beginning, because no
matter which source tree you wind up using, all of these
instructions are likely to assist you.
If you have problems building, make sure you've read all of
these instructions. At the bottom there is a list of known
bugs. If the problem you encounter is on this list, then there
is also a workaround. Just remember to be patient, and that I
(Dave Fancella) have successfully built Audacity on 3 different
Windows installations with 2 different versions of Windows (XP
and 2000 Pro). Knowing that it can be done is most of the battle.
---------------------------------
Cygwin STEP 1: Installing Cygwin
---------------------------------
1. Install Cygwin (from "http://www.cygwin.com"). If you have
plenty of bandwidth available, you should use the net
installer. Otherwise, you might be better off ordering a CD.
2. If you already have Cygwin installed, you should fire up
the installer again and compare your installed packages to
the list of packages needed.
3. Install the following packages:
(This is probably not a complete list. If you find that
you have to install more than this, make sure to let us know
which ones, so they can be added to this list)
Autoconf
Autoconf-devel (Autoconf 2.53 is required if you need to rebuild 'configure')
gettext-devel (for building the translation files. If you don't want to build these,
you don't need this package)
Automake
Automake-devel
binutils
gcc (only tested version is 3.3.1)
gcc-mingw
make
mingw-runtime
zip (required by configure, although gzip is actually used)
w32api
---------------------------------------
Cygwin STEP 2: Download and install wxWidgets
---------------------------------------
1. Go to http://www.wxwidgets.org/ and download wxWidgets v2.8.11 or greater. Make
sure you download the "wxAll" package that contains source code for all ports. The
Win32 port will not work for compiling Audacity, since it was compiled and installed
to work with MS Visual C++.
2. Untar the archive from the Cygwin command line, using a command like:
tar -xzvf (wxwindows).
3. From the top-level of the wxWidgets source tree, type './configure'.
** For some reason, I haven't been able to get Audacity to link to wxWidgets statically
under Cygwin. Since there are bigger fish to fry right now, I haven't dealt with it. I
would appreciate if someone gets it to work if you let me know what you did. To try this,
use './configure --disable-shared' for wxWidgets configuration.
When complete, type "make". When that's complete, "make install". If all goes well,
you will have wxWidgets installed in your Cygwin installation!
---------------------------------
Cygwin STEP 3: Download Audacity
---------------------------------
1. Go to http://audacity.sourceforge.net/ and download the Audacity source distribution.
Cygwin is currently experimental in the 1.2 branch and SVN head, but you must have at least
Audacity v1.2.0 sources.
2. From a cygwin prompt, go to the tarball that you downloaded and use a command like
'tar -xzvf (audacity tarball)' to open it.
-----------------------------------------
Cygwin STEP 4: Enable Ogg Vorbis Support
-----------------------------------------
Under Cygwin, Audacity does not compile out-of-the-box with Ogg Vorbis support. You have
a couple of hoops to jump through if you want this. Note, if you don't do this, you will
not have any audio codec available to Audacity! Lame is untested at this time and is
assumed not to work. If you try it with Lame, tell us!
By default, libogg and libvorbis configure with /usr/local as the prefix. For some
weird and inexplicable reason (i.e. I haven't figured it out yet) this doesn't work!
GCC will not find the libogg headers when you go to compile libvorbis if you install it
in the default location. On that token, GCC will not find libvorbis headers either, so
make sure you follow these instructions explicitly.
1. First you have to compile libogg. From the audacity source tree root, type
'cd lib-src/libogg'.
2. ./configure --prefix=/usr
3. make
4. make install
5. cd ../libvorbis # yep, now we have to compile vorbis
6. ./configure --prefix=/usr
7. make
8. make install
If all goes well, you will have Ogg Vorbis support in your Audacity executable.
------------------------------
Cygwin STEP 5: Build Audacity
------------------------------
This is the tricky part. :)
Audacity comes bundled with a number of libraries that it depends on. Usually you will
compile with those rather than any system installed libraries. If you would prefer to use
a system installed library, you'll have to pass --with-library=/path/to/library to configure.
There are two libraries that currently do not compile in cygwin. Those are Nyquist and
libid3tag. If you manage to build them, please send a patch (or instructions on how you
did it)!
If you didn't enable Ogg Vorbis support as described in the previous step, you will have to
pass --without-vorbis to configure, as shown.
1. ./configure --without-nyquist --without-id3tag [--without-vorbis]
2. make
3. ./audacity
4. If you have any problems or errors, read the next section.
--------------------------------------
Notes on building Audacity with Cygwin
--------------------------------------
These notes are provided because Cygwin support is experimental, and if you run into problems,
it might help to know what was needed to make it work on my computer.
The problems that appear when compiling Audacity under Cygwin are pretty consistent in how
they appear. The win32 port is written under the assumption that MSVC++ will be the
compiler used, and is the current standard and supported method of building Audacity.
Therefore, the problems that appear are mostly related to various symbols defined to make
Audacity compile out of the box on MSVC++. Other problems that surface will likely
be based on the fact that Cygwin passes itself to configure as a UNIX variant, and there
are various other symbols defined for UNIX variants. GNU/Linux is the standard UNIX variant
supported by Audacity, so you will have problems similar to what someone using OpenBSD might
encounter. The exception is Mac OS X, which is well-supported already.
Audacity uses a series of libraries that are either required or optional, and can be set
at compile time. The ones that are optional have --without switches for configure, the others
do not. So if a bundled library doesn't compile, your best bet is to try disabling the library
in your configure command line. If that doesn't work, you'll have to investigate the library
to see why it's not compiling.
PortAudio is required, and a Makefile is provided with Audacity to build it. PortMixer is not
required, but is recommended. This Makefile is also provided with Audacity. Note: to my
knowledge, the Makefile for PortAudio provided with Audacity is not present in the PortAudio
distribution. The one used with Audacity compiles PortAudio as a static library, and the
current Cygwin Makefile in the PortAudio distribution compiles as a dynamic library. Audacity
will compile with either one, but if you use the one provided with PortAudio you will have to
make sure the PortAudio dll is in Audacity's path. Of course, you shouldn't have any problems,
so this is probably more information than you need. :)
Libsamplerate is not supported at all with Cygwin, and it is doubtful that it will ever be
supported. If make tries to build it, --disable it. Use Libresample instead.
Libresample may require tweaking some #define statements in a fashion that is noted below.
Expat should compile out of the box. If not, you might be better off trying to install the version
of expat that ships with Cygwin. If configure fails to detect a system installed expat, this
is probably a bug and should be submitted to the Audacity developers. You can use the system-installed
expat by passing --with-expat=system to ./configure.
Any other libraries are probably not required, and if they fail to compile you should be able
to --disable them with configure.
-----------
Configwin.h
-----------
Configwin.h is a file that exists in the win directory from the root of Audacity's source tree.
You have three options for getting gcc to find this file. You can modify Audacity's Makefile to
include -I../win (or whatever a good path is that will point at the directory). You can copy
or move the configwin.h file to Audacity's source directory. Preferably, you will modify
configure.in to generate configwin.h in exactly the same fashion and location that it already
generates configunix.h.
A fourth option is to not use Configwin.h at all, but to modify the appropriate header files to
use configunix.h. Since this might be similar to opening a can of worms, I don't recommend this
approach.
---------------------
Dealing with #defines
---------------------
While working with this build system, there were a few files that failed to compile. Whenever
make bombs on a file, you need to carefully note the line it made the error on and open the
source file in a good syntax highlighting editor, or you can use Wordpad, which is neither good
nor syntax highlighting. Find the appropriate line on which the error occurred. Then scroll
up. Chances are very good that the line that triggered the error is wrapped in a #ifndef,
#if defined, or #ifdef block. The #define symbol is usually __WIN32__. You will be able to
get it to compile by making the line read something like this:
#if defined(__WIN32__) && !defined(__CYGWIN__)
In order for that to work, you will need to make sure that configure sets the __CYGWIN__ symbol to
be defined. You may be able to just add it to Audacity's Makefile, however. If you chose to use
the existing Configwin.h file and not have it generated by configure, then you should be able
to add a #define in it that defines __CYGWIN__.
Ultimately, if you find any of these options too difficult or time-consuming, you might consider
just deleting the entire block of code that is afflicted. Since that route will likely wind up
making the job hundreds of times more difficult than it actually is, it is not recommended.
-----------------
Linking Audacity
-----------------
The normal Unix flags for linking will not work with Audacity. Well, they will but they won't
include everything that needs to be linked. Before discussing what actually needs to be linked,
it would be beneficial to discuss the win32api and Cygwin. This discussion is surrounded on top
and bottom by **********'s, so if you already know this information you can easily skip it.
************************************************************
Cygwin is capable of compiling Windows programs that do not depend on the Cygwin runtime. It
does this by using the Mingw libraries and header files, which are available under the GPL.
However, in order to make these libraries available to GCC, which operates thinking that it's
running on a Unix system, the libraries must be stored and named in a location that GCC (or more
specifically, LD, the linker) will understand.
On GNU systems, and likely on proprietary Unix systems as well (although I don't know this as a
fact), a library that is to be linked dynamically will have the extension .so. A library that is
to be linked statically has the extension .a. Furthermore, in either case the text "lib" is
prepended to the library. When you pass a -l switch to GCC, GCC transparently passes this switch
to ld, the linker. The text associated with -l will name the library. For example: If you pass
-lfoobar, ld will receive it. In order to actually find the library, ld must prepend "lib" and
append ".a", and then search in its known library locations. So it will search for a file called
"libfoobar.a" in its known library locations.
The known library locations vary from system to system. On some GNU/Linux systems, the known
library locations are stored in a special file called "ldconfig". Cygwin does not, however. It
appears to know by magic where the libraries are stored. You will find them in /usr/lib,
/usr/local/lib, /usr/share/lib, and ~/.lib. If you look around your Cygwin installation, you'll
find a directory /usr/lib/w32api. In this directory is stored all of the Mingw libraries that
allow you to link to the win32api. If you've ever worked with MSVC++, you'll probably recognize
the names of these libraries. There's kernel32, odbc32, winmm, and the rest. But they're named
with ld's peculiar naming convention, libkernel32.a, libodbc32.a, and libwinmm.a respectively in
this example.
*************************************************************
From the MSVC++ project file, here are the libraries that need to be linked statically for
Audacity to successfully build.
kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib wsock32.lib winmm.lib
You can also obtain this list by modifying the Audacity Makefile to use
`wx-config --static --libs` instead of `wx-config --libs` which it already uses. Currently,
Audacity will not build with `wx-config --static --libs`. If you get it to work, let us know!
----------
Known Bugs
----------
First of all, expect your resulting build to work differently in little ways than a build made with
MSVC++.
Here is a list of currently known bugs in Audacity's build and the resulting executable. Any help
fixing these bugs would be greatly appreciated.
* Zoom does not center around cursor
* Audacity does not associate itself with filetypes (It's #if !defined out, the code works in
MSVC++)
* libsndfile fails to configure on some systems. If this happens, the known workaround is to
configure libsndfile manually and then configure audacity again.