Building On Linux

From Audacity Wiki
Revision as of 15:51, 22 June 2020 by Stevethefiddle (talk | contribs) (Instructions in linux/build.txt: initial tidying of some old notes)
Jump to: navigation, search
ToDo-2 Add
  • Instructions for building modules
  • Instructions for FFmpeg too:
This is the configure command Steve uses for testing/developing:
../configure  --with-lib-preference="local system" --with-ffmpeg="system" --disable-dynamic-loading --with-mod-script-pipe --with-mod-nyq-bench --enable-debug

For a "release build":
../configure  --with-lib-preference="local system" --with-ffmpeg="system" --disable-dynamic-loading
These are instructions for building on Linux

The build family of pages:

Instructions in linux/build.txt

These instructions are supplemental to the linux/build.txt in the source code.

Step-by-step instructions for building on Ubuntu are also periodically posted to the Audacity forum.


Python 2

In addition to the listed dependencies and standard build environment, Audacity currently requires Python 2 to be installed.

On Debian / Ubuntu, systems, if Python 2 is not already installed, it may be installed with:

sudo apt install python-minimal

or for Ubuntu 20.04:

sudo apt install python2.7-minimal
This dependency is scheduled for replacement by Python 3.


Instructions (Used by James on bionic)

Instructions for Building on Linux

Fuller instructions that cover:
    * Upgrading to gcc 4.9 on older Ubuntus
    * Optional libraries
can be found on our wiki at http://wiki.audacityteam.org/wiki/Building_On_Linux.

Some prerequisites:

- Audacity requires gcc 4.9 or later to build.

- CMake ( http://www.cmake.org/ ) is required to build the local copy of 
  the libsoxr resampling library used by Audacity.

On a modern Debian distro, e.g. Ubuntu 16.04 (bionic), you would do:

sudo apt-get install build-essential cmake

- libasound and gtk are required. Having gtk2 and gtk3 too  
  may not be required, but compilation works if both are.

- Auto-tools are also needed.

sudo apt-get install libasound2-dev libgtk2.0-dev libgtk-3-dev
sudo apt-get install autoconf automake

- Since you will be fetching code from git repositories you 
  will need git.

sudo apt-get install git git-gui gitk


wxWidgets:

 1) Clone wxWidgets and checkout 3.1.3 from the Audacity fork of the 
    wxWidgets project: 
       https://github.com/audacity/wxWidgets/....

    for example
      mkdir ./wxWidgets
      cd ./wxWidgets
      git clone --recurse-submodules https://github.com/audacity/wxWidgets/

    Don't be tempted to use Widgets already installed on Linux because this 
    will typically be a different version and will cause problems.              

    IF you forgot the --recurse-submodules, you can correct that later by:
      git submodule update --init

  2) Follow instructions for building at 
    https://github.com/audacity/wxWidgets/blob/v3.1.3/docs/gtk/install.txt

    So...

    mkdir buildgtk
    cd buildgtk
    ../configure --with-gtk
    make    

  3) Having got this far, it is well worth trying out building some wxWidgets
    examples to confirm that building has worked OK

Audacity:

These are old steps for using automake.  For 2.4.0 onwards we are using CMake
instead.  See later instructions.

  1) Create a 'build' subdirectory under Audacity and change to it.

  2) Now to build Audacity itself.
    Using a build directory (and .. in the command) keeps source and object files
    in separate directories.

    ../configure --with-lib-preference="local system"

    make
    make install  # as root

Bulb icon  
  • Optionally use make -j4 rather than just 'make'. With -j4 Audacity may build faster, on machines that have hard disks rather than SSD.
    • The reason is that the processor can make multiple requests to the hard drive, and get on with work on other cores whilst waiting for files to arrive.
  • If you have a browser open and 4Gb or less of RAM, close it, as the browser can hog memory that is needed for a fast build. You'll lose a lot of time to the OS paging memory in and out

CMake Build

Instructions for Installing recent CMake on Ubuntu.  

You'll need CMake 3.15 or higher.  These steps were tested with CMake 3.17.1.

1. Check whether you need to upgrade.

  cmake --version

2. Download the cmake install script from kitware https://cmake.org/download/
Get the binary version for linux, the bash script cmake-3.<something>.sh

3. Move it to the directory where you want to install CMake, possibly
/usr/local/bin (you could install it anywhere and then symlink to it)
I used /usr/local/bin so that I would not need to blow away the older copy 
in /usr/bin if it hadn't worked out.

4. Run the script
  sudo chmod +x cmake-3.<something>.sh
  sudo bash cmake-3.<something>.sh

You will answer n (no for an extra subdirectory) and then y.

5. Check that worked

  cmake --version

Then build Audacity

Instructions for Building Audacity using CMake

1. Make a build directory under the audacity git directory.

  cd audacity
  mkdir build-cmake
  cd build-cmake


2. Generate the makefiles

  cmake -DCMAKE_BUILD_TYPE=Release ..

3. Build Audacity 

  cmake --build . 
  make .

4. Run

  cd bin/Release
  ./audacity


About Box Details

The about box should show a git build identifier, if the source was under
git version control.  There will be no such identifier if you built from
the tarball.  Distros which ship a modified Audacity are encouraged to use
git and so to show their own git identifier.


Detailed Instructions

Steve Daulton. Updated 05Jun2020

Instructions for Building on Linux.
These steps have been tested on Xubuntu 18.04 and 20.04.


Note that only the current release version of the manual is available on-line. It is
therefore highly recommended to fetch the correct version of the manual and install it
on the local machine to ensure that the correct version of the manual is available for the
end user. See notes below for details.


Prerequisites:

1) Repository sources (sources.list) must include source code sources.
2) For MP3 / FFmpeg support, "non-free" repositories may need to be enabled.
3) Root access is required for installation (usually via "sudo").
4) Cmake version 3.15 or later.


Required dependencies:
(The package names below are those used by Ubuntu 20.04.)

For Debian / Ubuntu based distributions, these packages may be installed from the
command line with:
   $ sudo apt install <package-name>


build-essential
cmake >= 3.15
gcc 4.9 or later (gcc-7 recommended for Debian / Ubuntu)
libgtk2.0-dev
libasound2-dev
python2.7-minimal (This is due to be updated to Python 3 in the near future, but Audacity 2.4.1 requires Python 2.7)
libavformat-dev
libjack-jackd2-dev
WxWidgets 3.1 built with gtk2. (see note below)


Recommended:

timidity-daemon (for MIDI playback)
jackd2
python3 (for use with mod-script-pipe)


WxWidgets:

Audacity provides a patched version of wxWidgets 3.1 which includes some bug fixes.
This can be pulled in automatically by cmake if the following packages are installed:

git
libgtk2.0-dev

It is also possible to build against the system version of wxWidgets >= 3.0.
wxGTK3 is NOT currently recommended as there are known to be some issues.


Getting the Audacity source code:

The latest release version of Audacity is available from:
https://www.fosshub.com/Audacity.html
This is the recommended version for end users.

For developers, the current development code is available from Github.
Cloning the repository is recommended so that the source tree may easily be kept up to date.
https://github.com/audacity/audacity


Building Audacity:

After cloning or extracting the downloaded source code, open a terminal window and navigate
to the root of the source folder (the folder that contains the 'README.md' file).

   $ cd <audacity source code>
   $ mkdir build
   $ cd build
   $ cmake -DCMAKE_BUILD_TYPE=Release -Daudacity_use_ffmpeg=loaded ..
   $ make

Note: On a multi-core system, "make" can be made considerably quicker by adding the "-j" switch. For example, on a 4 core system: 

   $ make -j4


Options:

The options in the above example will produce a full release build, with FFmpeg enabled.
A full list of option can be found here: https://wiki.audacityteam.org/wiki/CMake_Options#Linux or may be listed in the terminal by running:

   $ cmake -LH


Pre-installation test:

Create a local folder for Audacity's settings. This folder will be only used for testing and will not be installed.

   $ cd bin/Release
   $ mkdir "Portable Settings"

Then launch Audacity:

   $ ./audacity



Installation:

Navigate back to the build directory:

   $ cd ../..

Then install:

   $ sudo make install

IMPORTANT: Prior to Audacity 2.4.2, mod-script-pipe must be manually copied into the installation folder.
IMPORTANT: Modules for Audacity must be built on the same day as Audacity is built.

   $ sudo cp -R ./bin/Release/modules /usr/local/share/audacity/



---

Additional Notes:

Jack Audio System:
Audacity can work with either jackd or jackd2.
Unless your Linux distribution runs Jack as the default sound system, it is recommended
to install QJackCtl to provide a convenient way to manage Jack.
End users are advised to read up on Jack if they wish to install it.



Installing the manual:


The Audacity manual is html, and is identical for Windows, Mac and Linux.
For release versions of Audacity, the manual may be downloaded as a ZIP archive from:
Current version: https://www.fosshub.com/Audacity.html
Old versions: https://www.fosshub.com/Audacity-old.html

Assuming that Audacity has been installed to /usr/local/ (default).
From the directory containing the manual ZIP archive:

   $ sudo unzip audacity-manual-2.4.2.zip -d /usr/local/share/audacity/help

Variations

These instructions for variations on building aren't in linux/build.txt in the Git repo.

gcc 4.9 on Ubuntu 14.04

If you're on Ubuntu 14.04, you need to upgrade the gcc compiler to at least 4.9.

 1) export CXX="g++-4.9" CC="gcc-4.9"
 
 2) g++-4.9 --version
You also must tell gcc to use c++11, so adapt the earlier configure command as follows:

    ../configure --with-lib-preference="local system" CXXFLAGS="-std=c++11"

Changes to makefile.am

If you've added or removed source files, you will need to change makefile.am to reflect that.

 autoreconf --no-recursive -i

Options

To see compile-time options you can set, you can type
  ./configure --help

For example you can enable and disable libraries.

Audacity 2.3.0 is now built by default with local ffmpeg and local libFlac.

Cache for Configure

This below is a note/tip from a developer, but untested by us:
If you want to do any development, you might want to generate a configure cache
and header dependencies:

  ./configure -C
  make dep

FFmpeg

Audacity should be able to link dynamically to FFmpeg 1.2 to 2.3.x (libav 0.8 to 10),
but many distributions have more recent versions that fail to link dynamically.
To work around this issue, Audacity may be configured to use the system
FFmpeg library and disable dynamic loading.
   $ ../configure --with-lib-preference="local system" --with-ffmpeg=system --disable-dynamic-loading

If this is done for both FFmpeg and LAME, then the "Libraries" option in Audacity's Preferences is not required and is automatically removed.
   $ ../configure --with-lib-preference="local system" --with-ffmpeg=system  --with-lame=system --disable-dynamic-loading

Other 'make' targets

These are some other make targets.

To uninstall:
   make uninstall #as root

To clean the build after modifying code:
   make clean

To clean and remove previous configure options:
   make distclean

Official Full Releases

Official full releases:

  • Executables: Have a GitIdent, visible in the about box build information, that says what branch was used in building.
  • Source-Code distros: Are minimal cut down versions from the release branch. We take out system libs that we expect to be provided by the distro, and that we haven't patched.

Updating .po files

With an official release, we ask translators to translate an updated .pot file. We create this with the following script:

cd locale
bash update_po_files.sh

Note: The script has the Audacity version number in it in three places, and all three should be updated before running it.

Updating GitIdent

  • We recommend that maintainers of linux distros that ship pre built copies of Audacity build with a GitIdent that reflects the state of their version of the branch including their patches to it.
  • We don't recommend having a Git ident when distributing in source code form, and we don't either in our

tarballs.

 git show -s --format="#define REV_LONG \"%H\"%n#define REV_TIME \"%cd\"%n" | tee ../src/RevisionIdent.h
 or easier use ../mac/get_gitident.sh

The CMake build adds the gitident automatically and this step is only needed with the automake builds.

Making a Minimal Tarball

eventually we will retire the page below and have a much shorter version right here

If using CMake build (you should use it!)

make minsrc

If using Autotools buildchain

 Clean your copy.  You check using -n and clean with -f.

 git clean -x -d -n
 git clean -x -d -f

 Now configure as if for building:

 ./configure --with-lib-preference="local system"

 Run the make tarball script:

 ./scripts/maketarball.sh verbose 

  Check the tarball is good for building:

  cd ../audacity-minsrc-x.y.z
  ./configure --with-lib-preference="local system"
  make -j4