Building On Linux

From Audacity Wiki
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 for building on Linux are in linux/build.txt in the Git repo.
Warning icon We currently have two different sets of instructions for building on Linux. You may get further with Steve's instructions than with James'. We plan to merge these instructions in time, and then have variations for where they diverge.

Instructions (Used by James on bionic)

Should that be libasound2-dev? I think I just used libasound and it was fine
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 libasound 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.1 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.1/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:

  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, close it, as the browser can hog memory that is needed for a fast build.

Instructions (Used by Steve on bionic)

Prerequisites:

1) Ubuntu 16.04-5 64-bit (including 3rd-party drivers, Flash, MP3 and other
media)

2) User must be a member of 'sudo' group (default on Ubuntu)

3) 'Source code' section of Ubuntu repositories must be enabled in sources
list.

Required:
  $ sudo apt-get install build-essential cmake gcc-5 autoconf
  $ sudo apt-get install libasound2-dev libgtk2.0-dev
  $ sudo apt-get install git

Recommended:
If not already installed:

libmp3lame0

libavformat-ffmpeg56
libavformat-dev

jackd2  (on a single user system, you will probably want to enable
real-time priority)
libjack-jackd2-0
libjack-jackd2-dev

------------------

WxWidgets:
Open a terminal window
  $ cd ~/
  $ git clone --recurse-submodules https://github.com/audacity/wxWidgets/wx311
  $ cd wx311
  $ mkdir buildgtk
  $ cd buildgtk

IMPORTANT - Ensure that the 'configure' and 'make' complete without errors
(don't worry about warnings). Note that the build will take several minutes
to complete.

  $ ../configure --with-gtk
  $ make j4  (the 'j' number = to number of processor cores)

IMPORTANT - Do not install WxWidgets. This is not the correct version for
Ubuntu 16.0.4.


TEST:
  $ cd samples/calendar
  $ make
  $ ./calendar
If successful, a calendar window should appear.
In the event of problems, refer to:
https://github.com/audacity/wxWidgets/blob/v3.1.1/docs/gtk/install.txt
------------------

Building Audacity 2.3.0

Download the Audacity source code.
At time of writing, 2.3.0 is available from:
https://www.fosshub.com/Audacity.html/audacity-minsrc-2.3.tar.xz

Extract the contents of the ZIP file. In this example we will extract to
the home directory. In a terminal window, navigate into the extracted
audacity directory.

  $ cd ~/audacity-minsrc-2.3.0
  $ mkdir build
  $ cd build

Note-1: <username> is your user name.
Note-2: If you did not install 'libavformat-dev', omit
--with-ffmpeg="system".

  $ ../configure  WX_CONFIG=/home/<username>/wx311/buildgtk/wx-config
--with-lib-preference="local system" --with-ffmpeg="system"
--disable-dynamic-loading

  $ make -j4 (the 'j' number = to number of processor cores)

TEST:
  $ ./audacity


INSTALL:
  $ sudo make install


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. If this is done for both FFmpeg
and the optional LAME library, 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 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

Making a Minimal Tarball

eventually we will retire the page below and have a much shorter version right here
 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