Difference between revisions of "Developing On Linux"

From Audacity Wiki
Jump to: navigation, search
(long-standing typo in ednote)
 
(61 intermediate revisions by 11 users not shown)
Line 1: Line 1:
{{Introrel|1=Users on Linux and Unix systems often compile Audacity from source code to experiment with the latest Beta version, or even the latest code in {{external|[http://audacity.sourceforge.net/community/developers#cvs CVS]}}. Linux users  may also need to compile either Audacity stable or Beta if there is no suitable Audacity package for their distribution. This page is a checklist of what you need to compile Audacity on Linux/Unix and the configure commands required.|2=If you need help with the basic steps in compiling Audacity, please see [[CompilingAudacityForBeginners|Compiling Audacity Step by Step Guide]].|3=[[Developing On Windows]]
+
{{ednote|'''Peter 15Jan17:''' [[ToDo-1]] This page really should be updated and maintained to deal with building the latest Audacity, otherwise it is of limited value.  }}
 +
{{alert|1=These instructions are for Audacity 2.1.1 or earlier. Audacity 2.1.2 requires wxWidgets 3.x (at time of writing, preferably 3.0.2). This page will be updated in due course.}}
 +
 
 +
{{Introrel|1=Users on Linux and Unix systems often compile Audacity from source code to experiment with the latest version, or even the latest code in [https://github.com/audacity/audacity GitHub]. This page describes the requirements for the latter case, i.e. compiling and making changes to development code that has not been released. |2=If you need to compile Audacity because there is no suitable Audacity package for your distribution, please see [[CompilingAudacityForBeginners|Compiling Audacity Step by Step Guide]].|3=[[Developing On Windows]]
 
   
 
   
* Also for building with Windows, see {{path|1=[install-directory]\win\compile.txt}}
+
* [[Building On Mac]]}}
* [[Developing On Mac]]
 
 
 
* '''Also see:''' {{external|1=[http://www.crotchett.com/kdevelop/index.html Tutorial: building Audacity on the Kdevelop IDE for KDE]}}}}
 
 
 
  
 
==Overview==
 
==Overview==
  
Compiling Audacity, or any GNU/Linux program for that matter, is basically a five stage process.  
+
Compiling Audacity, or any GNU/Linux application for that matter, is basically a six stage process.
#Install dependencies: other software necessary to run or compile.
+
#Install build tools: the applications needed to create other applications.
 +
#Install dependencies: other software used by the application you are trying to compile
 
#Download the source code into a local directory.
 
#Download the source code into a local directory.
 
#Configure the compile with options, if any.
 
#Configure the compile with options, if any.
Line 16: Line 16:
 
#Install
 
#Install
  
The first stage is crucial: it is a lack of necessary dependencies that ruins 99% of failed compiles. This page should help with that.
+
The first and second stages are crucial: lack of build tools and required dependencies are the cause of 99% of failed compiles. This page should help with that.
  
The standard commands to compile a piece of software for stages 3, 4 and 5 are as follows, issued from within the local directory containing the source code.
+
The standard commands to compile a piece of software for stages 4, 5 and 6 are as follows, issued from within the local directory containing the source code.
 
#CONFIGURE:  $ ./configure --[options-list]
 
#CONFIGURE:  $ ./configure --[options-list]
 
#COMPILE:  $ make
 
#COMPILE:  $ make
 
#INSTALL:  $ sudo make install
 
#INSTALL:  $ sudo make install
  
 
+
== Build Tools ==
== Obtaining Audacity ==
+
Most Linux distributions come with the core set of development tools already installed, but if not you will need to install the following packages, probably from your distribution's package manager:
 
 
* Stable tarball: The easiest way to get Audacity is to download a release from the {{external|[http://audacity.sourceforge.net Audacity website]}}.  All past releases of Audacity are archived on our {{external|1=[http://sourceforge.net/project/showfiles.php?group_id=6235 Sourceforge file release page]}}.
 
 
 
* CVS: The other main way to get Audacity is to use CVS - this is the best way if you want to actively develop Audacity, or keep up with the latest and greatest features.  For more information, see our {{external|[http://audacity.sourceforge.net/community/developers#cvs CVS page]}}. For a CVS interface on Mac to access our CVS repository, try {{external|1=[http://sourceforge.net/project/showfiles.php?group_id=10072&package_id=13913&release_id=534524 MacCVS]}} (this needs an external SSH client if you want to commit code to our repository) or {{external|1=[http://www.heilancoo.net/MacCVSClient/ MacCVSClient]}}. On Linux, BSD and other open source operating systems, command-line CVS clients are typically included in the default installation, or are available directly from the operating system repository.
 
 
 
 
 
== Prerequisites ==
 
(Note: These are for Audacity 1.3.x or CVS TRUNK, as there is no further development of the 1.2.x branch)
 
 
 
Audacity requires relatively few libraries and tools to build a minimum working program. There are then a larger number of option libraries that extend Audacity to enable more features and facilities. It's therefore up to you whether you install these or not. If you don't install them, then decide later you need the extra features, you will need to rebuild Audacity after installing the extra libraries.
 
 
 
Note that some Linux distributions make a practice of splitting each library they package into two parts, those required for running programs using the library, and all the other files only needed when compiling applications using the library. The latter are often found in a package with a -dev suffix to the name. For the purposes of these instructions, whenever a library is listed as being needed, it means that ''both parts'' are needed in order to compile Audacity.
 
 
 
=== Development Tools ===
 
Most Linux distributions come with the core set of development tools already installed, but as a minimum the following are required in order to compile Audacity:
 
 
* '''Shell'''. The configure script for Audacity is generated for a bourne-compatible shell. It is very unlikely that your system does not have one of these, but if in doubt, install the Bash shell.
 
* '''Shell'''. The configure script for Audacity is generated for a bourne-compatible shell. It is very unlikely that your system does not have one of these, but if in doubt, install the Bash shell.
* '''Make'''. Either GNU or BSD make will work with Audacity's makefiles, very few systems will not have one or the other.
+
* '''GNU Make''' Other Makes may work, but may well not. Make on any Linux system will be GNU make.
* '''gcc''' and '''g++'''. The C and C++ compilers from the {{external|[http://gcc.gnu.org/ GNU Compiler Collection]}}. No other compilers are supported by the Audacity development team, although we welcome patches to make Audacity compile with other compilers, for example the OpenSolaris compiler.
+
* '''{{external|[http://www.cmake.org/ CMake]}}''' CMake is required to build libsoxr which is the Audacity default resampling library.
 +
* '''GCC''' (at least the C and C++ compilers) from [http://gcc.gnu.org/ GNU Compiler Collection]. The only other compiler actively maintained by the Audacity development team is Microsoft's Visual C++, although we welcome patches to make Audacity compile with other compilers, for example the OpenSolaris compiler.
 +
* '''pkg-config'''
 +
* '''Autoconf''' Application which writes configure scripts. Needed to modify [[Audacity Configure Script|the build system]]
 +
* '''Automake''' Application which writes Makefiles. Needed to modify [[Audacity Configure Script|the build system]]
 +
* '''Git''' Source code version control application
 +
* '''Patch''' Application for applying patches to files
 +
* '''GDB''' The GNU Debugger (for debugging crashes; see note below)
 
* '''gettext'''. In order to build the translations for Audacity the {{external|[http://www.gnu.org/software/gettext/ GNU gettext]}} tools are required. These are normally installed in order to be able to build wxWidgets (see below).
 
* '''gettext'''. In order to build the translations for Audacity the {{external|[http://www.gnu.org/software/gettext/ GNU gettext]}} tools are required. These are normally installed in order to be able to build wxWidgets (see below).
  
=== WxWidgets ===
+
== Dependencies ==
The main requirement to build Audacity is {{external|[http://wxwidgets.org/ wxWidgets]}}. Both WX 2.6 (version 2.6.3 or higher) and WX 2.8 are supported, in both Unicode and ANSI forms. If you are installing wxWidgets only in order to build Audacity, you should install the latest 2.8.x release.
+
Audacity requires relatively few libraries and tools to build a minimum working application. There are then a larger number of optional libraries that extend Audacity to enable more features and facilities. It's therefore up to you whether you install these or not. If you don't install them, then decide later you need the extra features, you will need to rebuild Audacity after installing the extra libraries.
  
Audacity supports wxGTK for Linux (and other Unices), wxMac for Mac OS X (and wxMSW for Windows using either MSVC++ or Cygwin compilers). There is no support for wxMotif, wxX11 or other wx variants, as they are incomplete in key areas. Note that wxGTK 2.8.7 had a bug in it which disabled 2.6 compatibility and caused Audacity builds to fail. This is fixed in the source included in wxPython 2.8.7.1.
+
Note that some Linux distributions make a practice of splitting each library they package into two parts, those required for running applications using the library, and all the other files only needed when compiling applications using the library. The latter are often found in a package with a -dev suffix to the name. For the purposes of these instructions, whenever a library is listed as being needed, it means that ''both parts'' are needed in order to compile Audacity.
  
We also have some notes on the libraries already supplied with different [[Linux Distributions]]. For example, Ubuntu tend to update to newer libraries sooner than Debian do.
+
=== Prerequisites ===
 +
These libraries are required to build Audacity.
 +
==== wxWidgets ====
 +
The main requirement to build Audacity is [http://wxwidgets.org/ wxWidgets]. WX 3.0 is required, preferably 3.0.2. Older wxGTK 3.0.x versions may have bugs or missing features which stop Audacity working.  
  
 +
Audacity supports for Linux (and other Unices) requires the wxGTK implementation of wxWidgets. There is no support for wxQt, wxX11 or other wx variants, as they are incomplete in key areas. The GTK+ headers are also required as Audacity includes extensions to wxGTK which need the underlying toolkit headers to compile.
  
=== Note about Source Tarballs ===
+
Whilst building Audacity with a standard distribution-supplied wxGTK 3.0.2 package will work fine, it will be difficult to debug some features as wxWidgets will have been built in Release mode (even if the debugging symbols package has been installed). For Audacity development you will want to compile wxGTK from source in debug mode, thus obtaining both a full set of debug symbols and additional checking in the wxWidgets code. This copy of wxWidgets does not have to be installed as the system copy, provided that the WX_CONFIG environment variable is used to tell the configure script to use the debug build. For example if your debug build of wxWidgets is in /home/user/dev/wxbuild/ then run
 +
{{code|1=./configure WX_CONFIG=/home/user/dev/wxbuild/wx-config}}
  
Not all libraries that can be linked to in Audacity are included in our source tarballs, primarily because they are often already installed as system libraries on Linux systems. For example, libsndfile is a very widely used library for reading and writing WAV, AIFF and other uncompressed audio files. If you obtain Audacity via CVS, a copy of libsndfile is included in the sources, but it is not included in the source tarballs. If necessary it can be obtained from {{external|[http://www.mega-nerd.com/libsndfile/ http://www.mega-nerd.com/libsndfile/]}} and installed on your system. Similarly, libflac, libogg, libvorbis and SoundTouch are not included in the tarballs. If you need them, use the links in the "Optional Packages" table (below).
+
(by putting the environment variable after the configure script invocation, the setting will be cached by the configure script and you don't need to re-specify it when re-configuring Audacity as you would if it was placed before the invocation).
  
 +
We also have some notes on the libraries already supplied with different [[Linux Distributions]].  For example, Ubuntu tend to update to newer libraries sooner than Debian do.
  
== Optional Packages ==
+
==== libsndfile ====
 +
[http://www.mega-nerd.com/libsndfile/ libsndfile] is required to build Audacity. It is almost certainly already installed on your system, although you may have to install the development package (see above). It is rarely necessary to compile libsndfile from source, although a copy is also included in Audacity on GitHub.
  
The configure script of Audacity gives the option to link in or not to link in a number of 'optional' packages. 'Optional' as some are more optional than others.
+
<div id="optional"></div>
 
+
=== Packages and features options ===
There are possibilities surrounding the following packages:
+
{{ednote|'''Peter 14Feb19:''' [[ToDo-1]] QucickTime has been deprecated by Apple}}
 +
The configure script of Audacity gives the option to link in or not to link in a number of optional packages or features, and to link to a local or system version of the required libsndfile library.
  
 +
In the case of resampling libraries there is a choice of three packages but only one or none must be used.
  
 
{| style="background:#F9F9F9; border:1px solid #CCCCCC" cellpadding="5 px"
 
{| style="background:#F9F9F9; border:1px solid #CCCCCC" cellpadding="5 px"
 
|-
 
|-
|valign="top"|id3tag
+
|width="20%" valign="top"|[[Audio Units|audiounits]]
|use {{external|1=[http://sourceforge.net/project/showfiles.php?group_id=12349&package_id=87002 libid3tag]}} for MP3 ID3 tag support  
+
|enable Audio Units plug-in support (Mac only) [default=auto]
 +
|-
 +
|valign="top"|[[expat]]
 +
|which expat to use for XML file support: [local], [system]
 +
|-
 +
|valign="top"|[http://www.ffmpeg.org/ FFmpeg]
 +
|use [[FFmpeg integration|FFmpeg]] for import and export support  
 
|-
 
|-
|valign="top"|{{external|[http://www.ladspa.org/ LADSPA]}}          
+
|valign="top"|[http://gstreamer.freedesktop.org/ GStreamer]           
|compile with LADSPA plug-in support [default=yes]
+
|include GStreamer import/export support
 
|-
 
|-
|width="20%" valign="top"|{{external|[http://flac.sourceforge.net/ libflac]}}
+
|valign="top"|[http://www.ladspa.org/ ladspa]        
|[local], [system], [none] - enable FLAC support [default=none]
+
|enable LADSPA plug-in support [default=yes]
 
|-
 
|-
|valign="top"|{{external|[http://www.mars.org/home/rob/proj/mpeg/ libmad]}}  
+
|valign="top"|[http://flac.sourceforge.net/ libflac]
 +
|use libFLAC for FLAC support: [local], [system], [none]
 +
|-
 +
|valign="top"|[http://sourceforge.net/project/showfiles.php?group_id=12349&package_id=87002 libid3tag]
 +
|use libid3tag for MP3 ID3 tag support
 +
|-
 +
|valign="top"|[http://www.mars.org/home/rob/proj/mpeg/ libmad]   
 
|use libmad for mp3 decoding support
 
|use libmad for mp3 decoding support
 
|-
 
|-
 
|valign="top"|[[libresample]]
 
|valign="top"|[[libresample]]
|use libresample: [yes], [no]
+
|Alternative sample rate conversion algorithm instead of the default, recommended libsoxr: [local], [system], [none]
 
|-
 
|-
|valign="top"|{{external|[http://www.mega-nerd.com/SRC/ libsamplerate]}}    
+
|valign="top"|[http://www.mega-nerd.com/SRC/ libsamplerate]   
|alternatively, use libsamplerate (instead of libresample): [local], [system], [none]
+
|Alternative sample rate conversion algorithm instead of the default, recommended libsoxr: [local], [system], [none]. Should not be used if VST plug-in support is enabled, due to licensing reasons.
 
|-
 
|-
|valign="top"|{{external|[http://www.mega-nerd.com/libsndfile/ libsndfile]}}    
+
|valign="top"|[http://www.mega-nerd.com/libsndfile/ libsndfile]   
 
|choose which libsndfile to use: [local], [system]
 
|choose which libsndfile to use: [local], [system]
 
|-
 
|-
|valign="top"|{{external|[http://www.portaudio.com/ PortAudio]}} 
+
|valign="top"|[[Libsoxr|libsoxr]]  
|which version of [[PortAudio]]  to use (=[v18,v19]) [stable default=v18], [Beta default=v19] &nbsp; &nbsp;
+
|Audacity's default sample rate conversion algorithm offering both high quality and high speed: [local], [system], [none]
 
|-
 
|-
|valign="top"|[[PortMixer]]
+
|valign="top"|[http://www.twolame.org/ libtwolame] 
|compile with PortMixer [default=yes]
+
|use libtwolame for MP2 export support
 +
|-
 +
|valign="top"|[http://www.vamp-plugins.org/ libvamp]     
 +
|use libvamp for Vamp plug-in support [default=yes]
 +
|-
 +
|valign="top"|[http://www.xiph.org/ogg/vorbis/ libvorbis]      
 +
|use libvorbis for Ogg Vorbis support
 +
|-
 +
|valign="top"|[http://lv2plug.in/ LV2]      
 +
|use lv2 for LV2 plug-in support
 +
|-
 +
|valign="top"|[[Midi|midi]]
 +
|use [http://sourceforge.net/apps/trac/portmedia/wiki/portsmf portSMF] for Midi support
 +
|-
 +
|valign="top"|[http://www-2.cs.cmu.edu/~music/music.software.html nyquist]
 +
|enable [[Nyquist Audio Programming|Nyquist]] plug-in support [default=yes]
 
|-
 
|-
|valign="top"|{{external|[http://www-2.cs.cmu.edu/~music/music.software.html Nyquist]}}
+
|valign="top"|[http://www.portaudio.com/ portaudio]
|compile with Nyquist support [default=yes]
+
|use portaudio v19
 
|-
 
|-
|valign="top"|{{external|[http://www.surina.net/soundtouch/ SoundTouch]}} 
+
|valign="top"|portmixer
|compile with [[SoundTouch]]  [default=yes] '''^'''
+
|compile with PortMixer [default=yes]
 
|-
 
|-
|valign="top"|{{external|[http://www.xiph.org/ogg/vorbis/ vorbis]}}     
+
|valign="top"|[http://en.wikipedia.org/wiki/QuickTime quicktime]
|enable ogg vorbis support
+
|enable QuickTime import support (Mac only) [default=auto]
 
|-
 
|-
|&nbsp;
+
|valign="top"|[http://sourceforge.net/projects/sbsms/files/ sbsms] 
 +
|use libsbsms for slower, more accurate pitch and tempo changing
 
|-
 
|-
|valign="top"|help
+
|valign="top"|[http://www.surina.net/soundtouch/ soundtouch] 
|make the help file "audacity-1.2-help.htb" [default=yes]
+
|use [[SoundTouch]] for pitch and tempo changing  [default=yes]  
 
|}
 
|}
  
:<div style="width:70%;font-size:90%">'''^'''  As of May 2008, Audacity pkg-config will not correctly detect the SoundTouch library on Debian and Debian-derived systems like Ubuntu, due to a {{external|1=[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=476699 Debian bug]}}. '''Workround:''' Using CVS from 5th May 2008 or later, either install the latest version of libSoundTouch (1.3.1), or symlink the installed file (/usr/lib/pkgconfig/libSoundTouch.pc) to the correct file name (/usr/lib/pkgconfig/soundtouch-1.0.pc). For example:</div>
+
== Obtaining Audacity ==
{{code|sudo ln -s /usr/lib/pkgconfig/libSoundTouch.pc  &nbsp; /usr/lib/pkgconfig/soundtouch-1.0.pc  &nbsp;}}
+
For development you will always want to obtain the GitHub HEAD version of Audacity so you can stay abreast of the latest changes. For more information, see our [https://web.audacityteam.org/community/developers development code download] page and [[GitHub]].  
  
 
+
Configure possibilities for libraries range from whether to include them or not, and whether to use local or system versions. In almost all cases these are standard libraries, and only provided in GitHub for convenience, so if you have up-to-date versions installed as shared libraries you should select the external copies. The exceptions are Nyquist (which we have modified to integrate it with Audacity), and PortAudio (which has had to be patched to make it work).
 
 
The following syntax is used as a parameter to the configure script to enable or disable a package or to pass further information about the package.
 
 
 
{{code|<nowiki>--with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]</nowiki><br><nowiki>
 
--without-PACKAGE      do not use PACKAGE (same as --with-PACKAGE=no)</nowiki>}}
 
 
 
 
 
The possibilities range from whether to include them or not to whether to use local or system versions. In almost all cases these are standard libraries, and only provided in CVS for convenience, so if you have up to date versions installed as shared libraries you should select the external copies. The exceptions are libresample (which is developed as part of Audacity), Nyquist (which we have modified to integrate it with Audacity), and PortAudio (which has had to be patched to make it work).
 
  
 
'''Examples:'''
 
'''Examples:'''
Line 135: Line 156:
 
{{code|<nowiki>--without-nyquist</nowiki>}}
 
{{code|<nowiki>--without-nyquist</nowiki>}}
  
 +
== Compiling on Unix ==
  
== Compiling on Unix ==
+
To compile Audacity on Linux (or for that matter, Mac and most other Unix systems), use a modified "configure; make" sequence:
 +
{{code|1=./configure CXXFLAGS="-std=gnu++11"<br>make}}
 +
 
 +
However, you may want to start by running ./configure --help first to see the options, and possibly add special options.
 +
 
 +
If you are re-compiling from Git HEAD you can re-generate the configure script by running
 +
{{code|autoreconf --no-recursive -i}}
 +
in the top level directory first.
  
To compile Audacity on Linux (or for that matter, Mac OS X and most other Unix systems), use the standard "configure; make" sequence:
+
In order to use ALSA devices with PortAudio v19 it is necessary to have the ALSA development library installed before compiling Audacity.  In Debian-based Linux including Ubuntu and Ubuntu Studio, for example, this can be installed by running:
{{code|./configure<br>make}}
+
{{code|sudo apt-get install libasound2-dev}}
  
 +
On other distributions for example RHEL/CentOS, the required package is called "alsa-lib-devel".
  
However, you may want to start by running ./configure --help first to see the options, and possibly add special options.
+
== Modifying the source ==
  
If you are compiling from a CVS checkout, then you can re-generate the configure script by running
+
=== Applying and reverting patches ===
{{code|autoreconf}}
 
  
 +
To apply a [[SubmittingPatches|patch]] use the following syntax ( see [http://linux.die.net/man/1/patch help with patch syntax and the <i>p</i> or <i>strip</i> option] ) :
 +
{{code|patch -p0 < <i>name of patch file being applied</i>}}
  
in the top level directory first. If this causes trouble, with errors like:
+
To revert a patch:
{{code|<nowiki>configure: warning: CC=gcc: invalid host type</nowiki><br><nowiki>configure: warning: CXX=g++: invalid host type</nowiki><br>configure: error: can only configure for one host and one target at a time<br>configure: error: /bin/sh './configure' failed for lib-src/portaudio-v19}}
+
{{code|patch -p0 -R < <i>name of patch file being reverted</i>}}
  
 +
=== Useful rules when modifying the source ===
 +
{{note|Whenever modifying the source, delete "audacity" in the root of the build tree and delete "audacity" in src/ before following the below.}}
 +
If you modify a file or an #include in a file:
  
then try prefixing the configure command with "env -i":
+
:'''make'''
{{code|<nowiki>env -i ./configure --without-portmixer --with-portaudio=v19</nowiki>}}
 
  
 +
If you modify configure.ac, Makefile.am, or any files in m4/ :
  
This appears to be fixed for Audacity 1.2.4 and onwards.
+
:''' autoreconf --no-recursive -i; ./configure; make'''
  
In order to use ALSA devices with PortAudio v19 (the default for Audacity 1.3.x beta) it is necessary to have the ALSA development library installed before compiling Audacity.  In Ubuntu Studio, for example, this can be installed by running:
+
If you add or remove files:
{{code|sudo apt-get install libasound2-dev}}
 
  
 +
:'''./configure; make'''
  
== Example dependencies: Audacity 1.3.4/Ubuntu 7.10 ==
+
== Old example dependencies: Audacity 1.3.4/Ubuntu 7.10 ==
 
   
 
   
 
Dependencies:
 
Dependencies:
Line 193: Line 227:
 
{{code|$ sudo apt-get install gettext libasound2-dev libflac-dev libflac++-dev libgtk2.0-dev libgtk-dev libid3tag0-dev libjack0.100.0-dev libmad0-dev libogg-dev libtwolame0 libtwolame-dev libvorbis-dev libwxbase2.6-dev libwxgtk-dev libwxgtk2.6-dev twolame portaudio19-dev wx2.6-headers zlib1g-dev}}  
 
{{code|$ sudo apt-get install gettext libasound2-dev libflac-dev libflac++-dev libgtk2.0-dev libgtk-dev libid3tag0-dev libjack0.100.0-dev libmad0-dev libogg-dev libtwolame0 libtwolame-dev libvorbis-dev libwxbase2.6-dev libwxgtk-dev libwxgtk2.6-dev twolame portaudio19-dev wx2.6-headers zlib1g-dev}}  
  
 
+
{{ednote|'''Gale 26Jun15:''' [[ToDo-2]] The "suggested ./configure command for full functionality" 
 +
seems to be redundant as the default ./configure would now do that. Maybe better to show a non-default configure command that e.g. used system LV2 and local PortAudio.}} 
 
A suggested ./configure command for full functionality:
 
A suggested ./configure command for full functionality:
  
 
{{code|$  ./configure --with-libvorbis --with-libflac --with-libid3tag --with-soundtouch}}
 
{{code|$  ./configure --with-libvorbis --with-libflac --with-libid3tag --with-soundtouch}}
 +
 +
 +
{{ednote|'''Steve 01Jul15:''' Recent versions of Ubuntu, Mint, Debian and their derivatives will pull in WxGTK3.x if "sudo apt-get build-dep audacity" is used, so commenting out the next paragraph.
 +
 +
 +
A more up-to-date set of steps on Ubuntu to obtain wxWidgets then use "sudo apt-get build-dep audacity" to build the Audacity dependencies is available in [[CompilingAudacityForBeginners#simple|Compiling Audacity for Beginners]].}}
 +
 +
See also [[CompilingAudacityForBeginners#simple|Compiling Audacity for Beginners]].
 +
 +
== KDevelop ==
 +
 +
[http://www.kdevelop.org/ KDevelop] is a free, open source and cross-platform [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment] (IDE) produced by [http://www.kde.org/ KDE]. Although not officially supported by Audacity, KDevelop can in principle be used for building or developing Audacity on Linux using any desktop environment. There is some information on building Audacity on KDevelop [http://www.kdevelop.org/phorum5/read.php?2,31411 here] - note the link thereon to www.crotchett.com for a tutorial on Audacity and KDevelop is no longer retrievable.
 +
 +
==Problems with GDB and keyboard/mouse grabs==
 +
 +
Running GUI applications in GDB is tricky, because GDB doesn't understand keyboard/mouse grabbing.  In most X11 applications when you're in a menu, dragging a slider, or similar, the application grabs control of the keyboard or mouse to prevent other applications from getting their events until the drag/menu action is over.  If you hit a breakpoint with the keyboard or mouse grabbed you're really stuck.  For this reason, people often debug in a nested X server like Xephyr (similar to the older Xnest).  Here's how you do that:
 +
 +
* Install the Xephyr package.  On Ubuntu it's called xserver-xephyr... probably similar in other distros
 +
* Install a simple window manager to run in the nested X server... I usually use wm2, because it doesn't require any configuration.
 +
* Run Xephyr.  To get a 1024x768 window with address :5 (usually your main X server is at :0, and sometimes if you have two monitors the second is at :1) run {{code|$ Xephyr :5 -screen 1024x768}}
 +
* Start up wm2 (or whatever you like for a simple window manager) in the Xephyr window: {{code|<nowiki>$ DISPLAY=:5 wm2</nowiki>}}
 +
* Pop open a new terminal for GDB.  Set the shell variable DISPLAY to ":5" so that all X11 applications started from that shell will use the new server at :5: {{code|<nowiki>$ DISPLAY=:5</nowiki>}}
 +
* cd to the source tree and run gdb as usual.  The Audacity window should come up inside the xephyr window.
 +
 +
If your keyboard map is messed up in the Audacity window you can run the following command, which copies the keyboard map from your main display to the new one
 +
{{code|$ xkbcomp :0 :5}}
 +
 +
Alternately [http://www.ogre3d.org/forums/viewtopic.php?t=20690 there's a way to force-ungrab the KB/mouse], but it requires some X configuration (I like Xephyr, but you might prefer this). '''AWD:''' The force-ungrab stuff has apparently been removed from recent versions of X.org. So you shouldn't rely on it unless you're specifically using an old version that still has this feature.
  
 
[[Category:Linux and Unix Platform]] [[Category:For Developers]]
 
[[Category:Linux and Unix Platform]] [[Category:For Developers]]

Latest revision as of 09:55, 20 July 2019

Peter 15Jan17: ToDo-1 This page really should be updated and maintained to deal with building the latest Audacity, otherwise it is of limited value.
Warning icon These instructions are for Audacity 2.1.1 or earlier. Audacity 2.1.2 requires wxWidgets 3.x (at time of writing, preferably 3.0.2). This page will be updated in due course.


Users on Linux and Unix systems often compile Audacity from source code to experiment with the latest version, or even the latest code in GitHub. This page describes the requirements for the latter case, i.e. compiling and making changes to development code that has not been released.
If you need to compile Audacity because there is no suitable Audacity package for your distribution, please see Compiling Audacity Step by Step Guide.
 
Related article(s):

Overview

Compiling Audacity, or any GNU/Linux application for that matter, is basically a six stage process.

  1. Install build tools: the applications needed to create other applications.
  2. Install dependencies: other software used by the application you are trying to compile
  3. Download the source code into a local directory.
  4. Configure the compile with options, if any.
  5. Compile
  6. Install

The first and second stages are crucial: lack of build tools and required dependencies are the cause of 99% of failed compiles. This page should help with that.

The standard commands to compile a piece of software for stages 4, 5 and 6 are as follows, issued from within the local directory containing the source code.

  1. CONFIGURE: $ ./configure --[options-list]
  2. COMPILE: $ make
  3. INSTALL: $ sudo make install

Build Tools

Most Linux distributions come with the core set of development tools already installed, but if not you will need to install the following packages, probably from your distribution's package manager:

  • Shell. The configure script for Audacity is generated for a bourne-compatible shell. It is very unlikely that your system does not have one of these, but if in doubt, install the Bash shell.
  • GNU Make Other Makes may work, but may well not. Make on any Linux system will be GNU make.
  • CMake  CMake is required to build libsoxr which is the Audacity default resampling library.
  • GCC (at least the C and C++ compilers) from GNU Compiler Collection. The only other compiler actively maintained by the Audacity development team is Microsoft's Visual C++, although we welcome patches to make Audacity compile with other compilers, for example the OpenSolaris compiler.
  • pkg-config
  • Autoconf Application which writes configure scripts. Needed to modify the build system
  • Automake Application which writes Makefiles. Needed to modify the build system
  • Git Source code version control application
  • Patch Application for applying patches to files
  • GDB The GNU Debugger (for debugging crashes; see note below)
  • gettext. In order to build the translations for Audacity the GNU gettext  tools are required. These are normally installed in order to be able to build wxWidgets (see below).

Dependencies

Audacity requires relatively few libraries and tools to build a minimum working application. There are then a larger number of optional libraries that extend Audacity to enable more features and facilities. It's therefore up to you whether you install these or not. If you don't install them, then decide later you need the extra features, you will need to rebuild Audacity after installing the extra libraries.

Note that some Linux distributions make a practice of splitting each library they package into two parts, those required for running applications using the library, and all the other files only needed when compiling applications using the library. The latter are often found in a package with a -dev suffix to the name. For the purposes of these instructions, whenever a library is listed as being needed, it means that both parts are needed in order to compile Audacity.

Prerequisites

These libraries are required to build Audacity.

wxWidgets

The main requirement to build Audacity is wxWidgets. WX 3.0 is required, preferably 3.0.2. Older wxGTK 3.0.x versions may have bugs or missing features which stop Audacity working.

Audacity supports for Linux (and other Unices) requires the wxGTK implementation of wxWidgets. There is no support for wxQt, wxX11 or other wx variants, as they are incomplete in key areas. The GTK+ headers are also required as Audacity includes extensions to wxGTK which need the underlying toolkit headers to compile.

Whilst building Audacity with a standard distribution-supplied wxGTK 3.0.2 package will work fine, it will be difficult to debug some features as wxWidgets will have been built in Release mode (even if the debugging symbols package has been installed). For Audacity development you will want to compile wxGTK from source in debug mode, thus obtaining both a full set of debug symbols and additional checking in the wxWidgets code. This copy of wxWidgets does not have to be installed as the system copy, provided that the WX_CONFIG environment variable is used to tell the configure script to use the debug build. For example if your debug build of wxWidgets is in /home/user/dev/wxbuild/ then run

./configure WX_CONFIG=/home/user/dev/wxbuild/wx-config

(by putting the environment variable after the configure script invocation, the setting will be cached by the configure script and you don't need to re-specify it when re-configuring Audacity as you would if it was placed before the invocation).

We also have some notes on the libraries already supplied with different Linux Distributions. For example, Ubuntu tend to update to newer libraries sooner than Debian do.

libsndfile

libsndfile is required to build Audacity. It is almost certainly already installed on your system, although you may have to install the development package (see above). It is rarely necessary to compile libsndfile from source, although a copy is also included in Audacity on GitHub.

Packages and features options

Peter 14Feb19: ToDo-1 QucickTime has been deprecated by Apple

The configure script of Audacity gives the option to link in or not to link in a number of optional packages or features, and to link to a local or system version of the required libsndfile library.

In the case of resampling libraries there is a choice of three packages but only one or none must be used.

audiounits enable Audio Units plug-in support (Mac only) [default=auto]
expat which expat to use for XML file support: [local], [system]
FFmpeg use FFmpeg for import and export support
GStreamer include GStreamer import/export support
ladspa enable LADSPA plug-in support [default=yes]
libflac use libFLAC for FLAC support: [local], [system], [none]
libid3tag use libid3tag for MP3 ID3 tag support
libmad use libmad for mp3 decoding support
libresample Alternative sample rate conversion algorithm instead of the default, recommended libsoxr: [local], [system], [none]
libsamplerate Alternative sample rate conversion algorithm instead of the default, recommended libsoxr: [local], [system], [none]. Should not be used if VST plug-in support is enabled, due to licensing reasons.
libsndfile choose which libsndfile to use: [local], [system]
libsoxr Audacity's default sample rate conversion algorithm offering both high quality and high speed: [local], [system], [none]
libtwolame use libtwolame for MP2 export support
libvamp use libvamp for Vamp plug-in support [default=yes]
libvorbis use libvorbis for Ogg Vorbis support
LV2 use lv2 for LV2 plug-in support
midi use portSMF for Midi support
nyquist enable Nyquist plug-in support [default=yes]
portaudio use portaudio v19
portmixer compile with PortMixer [default=yes]
quicktime enable QuickTime import support (Mac only) [default=auto]
sbsms use libsbsms for slower, more accurate pitch and tempo changing
soundtouch use SoundTouch for pitch and tempo changing [default=yes]

Obtaining Audacity

For development you will always want to obtain the GitHub HEAD version of Audacity so you can stay abreast of the latest changes. For more information, see our development code download page and GitHub.

Configure possibilities for libraries range from whether to include them or not, and whether to use local or system versions. In almost all cases these are standard libraries, and only provided in GitHub for convenience, so if you have up-to-date versions installed as shared libraries you should select the external copies. The exceptions are Nyquist (which we have modified to integrate it with Audacity), and PortAudio (which has had to be patched to make it work).

Examples:

To enable support for ogg files:

--with-vorbis=[local|system]


To use an external sndfile library (which you have previously built and installed):

--with-libsndfile=system


To disable Nyquist:

--without-nyquist

Compiling on Unix

To compile Audacity on Linux (or for that matter, Mac and most other Unix systems), use a modified "configure; make" sequence:

./configure CXXFLAGS="-std=gnu++11"
make

However, you may want to start by running ./configure --help first to see the options, and possibly add special options.

If you are re-compiling from Git HEAD you can re-generate the configure script by running

autoreconf --no-recursive -i

in the top level directory first.

In order to use ALSA devices with PortAudio v19 it is necessary to have the ALSA development library installed before compiling Audacity. In Debian-based Linux including Ubuntu and Ubuntu Studio, for example, this can be installed by running:

sudo apt-get install libasound2-dev

On other distributions for example RHEL/CentOS, the required package is called "alsa-lib-devel".

Modifying the source

Applying and reverting patches

To apply a patch use the following syntax ( see help with patch syntax and the p or strip option ) :

patch -p0 < name of patch file being applied

To revert a patch:

patch -p0 -R < name of patch file being reverted

Useful rules when modifying the source

Whenever modifying the source, delete "audacity" in the root of the build tree and delete "audacity" in src/ before following the below.

If you modify a file or an #include in a file:

make

If you modify configure.ac, Makefile.am, or any files in m4/ :

autoreconf --no-recursive -i; ./configure; make

If you add or remove files:

./configure; make

Old example dependencies: Audacity 1.3.4/Ubuntu 7.10

Dependencies:

gettext 
libasound2-dev 
libflac-dev 
libflac++-dev 
libgtk2.0-dev
libgtk-dev 
libid3tag0-dev 
libjack0.100.0-dev 
libmad0-dev 
libogg-dev 
libtwolame0 
libtwolame-dev 
libvorbis-dev 
libwxbase2.6-dev 
libwxgtk-dev 
libwxgtk2.6-dev 
twolame 
portaudio19-dev 
wx2.6-headers 
zlib1g-dev 


A suggested apt-get command to install the above dependencies:

$ sudo apt-get install gettext libasound2-dev libflac-dev libflac++-dev libgtk2.0-dev libgtk-dev libid3tag0-dev libjack0.100.0-dev libmad0-dev libogg-dev libtwolame0 libtwolame-dev libvorbis-dev libwxbase2.6-dev libwxgtk-dev libwxgtk2.6-dev twolame portaudio19-dev wx2.6-headers zlib1g-dev
Gale 26Jun15: ToDo-2 The "suggested ./configure command for full functionality" seems to be redundant as the default ./configure would now do that. Maybe better to show a non-default configure command that e.g. used system LV2 and local PortAudio.

A suggested ./configure command for full functionality:

$ ./configure --with-libvorbis --with-libflac --with-libid3tag --with-soundtouch


Steve 01Jul15: Recent versions of Ubuntu, Mint, Debian and their derivatives will pull in WxGTK3.x if "sudo apt-get build-dep audacity" is used, so commenting out the next paragraph.


A more up-to-date set of steps on Ubuntu to obtain wxWidgets then use "sudo apt-get build-dep audacity" to build the Audacity dependencies is available in Compiling Audacity for Beginners.

See also Compiling Audacity for Beginners.

KDevelop

KDevelop is a free, open source and cross-platform Integrated Development Environment (IDE) produced by KDE. Although not officially supported by Audacity, KDevelop can in principle be used for building or developing Audacity on Linux using any desktop environment. There is some information on building Audacity on KDevelop here - note the link thereon to www.crotchett.com for a tutorial on Audacity and KDevelop is no longer retrievable.

Problems with GDB and keyboard/mouse grabs

Running GUI applications in GDB is tricky, because GDB doesn't understand keyboard/mouse grabbing. In most X11 applications when you're in a menu, dragging a slider, or similar, the application grabs control of the keyboard or mouse to prevent other applications from getting their events until the drag/menu action is over. If you hit a breakpoint with the keyboard or mouse grabbed you're really stuck. For this reason, people often debug in a nested X server like Xephyr (similar to the older Xnest). Here's how you do that:

  • Install the Xephyr package. On Ubuntu it's called xserver-xephyr... probably similar in other distros
  • Install a simple window manager to run in the nested X server... I usually use wm2, because it doesn't require any configuration.
  • Run Xephyr. To get a 1024x768 window with address :5 (usually your main X server is at :0, and sometimes if you have two monitors the second is at :1) run
$ Xephyr :5 -screen 1024x768
  • Start up wm2 (or whatever you like for a simple window manager) in the Xephyr window:
$ DISPLAY=:5 wm2
  • Pop open a new terminal for GDB. Set the shell variable DISPLAY to ":5" so that all X11 applications started from that shell will use the new server at :5:
$ DISPLAY=:5
  • cd to the source tree and run gdb as usual. The Audacity window should come up inside the xephyr window.

If your keyboard map is messed up in the Audacity window you can run the following command, which copies the keyboard map from your main display to the new one

$ xkbcomp :0 :5

Alternately there's a way to force-ungrab the KB/mouse, but it requires some X configuration (I like Xephyr, but you might prefer this). AWD: The force-ungrab stuff has apparently been removed from recent versions of X.org. So you shouldn't rely on it unless you're specifically using an old version that still has this feature.