Difference between revisions of "Building On Mac"

From Audacity Wiki
Jump to: navigation, search
(Install Xcode 3.2.6)
m (+deprecated)
 
(56 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{IntroNoItal|This guide will help you establish a working development environment for Audacity on OS X Snow Leopard, Lion or Mountain Lion. <p>The steps detailed below are focused on getting you building Audacity as quickly and easily as possible, but you may use the environment for general development as well.</p>}}  
+
{{deprecated|https://github.com/audacity/audacity/blob/master/BUILDING.md}}
 +
{{ednote|1=[[ToDo-2]] Add<br>
 +
* Instructions for building modules
 +
}}{{Intro|1='''These are instructions for building on Mac'''
  
{{advice|1=
+
The build family of pages:
Xcode 4 (steps 2 and 7) is not required on Snow Leopard. Xcode 4 is strongly recommended on Lion or later (it is required on those systems for [http://en.wikipedia.org/wiki/MacPorts MacPorts], [http://en.wikipedia.org/wiki/Fink Fink] and almost any other package management or development-related product).}} {{ednote|1='''Gale 21Jan13:''' Hi Leland, can you be a bit more specific in the advice div above. On a new system that lacks MacPorts or Fink, you can do without either of those and you can use only Xcode 3? You can ignore steps 2 and 7 in the Contents entirely?
+
* [[Building On Windows]]
* '''Leland 21Jan13:''' Is that better Gale?  I'm starting to think that I should just leave that note out entirely since it may be clearer for users to just do the steps from top to bottom.  What do ya think?
+
* [[Building On Mac]]
* '''Gale 17Feb13:''' I've shortened the advice to make it look more or less mandatory to use it on Lion or greater, and more or less mandatory to omit it on Snow Leopard. But change it if it's too dogmatic.:=) }}  
+
* [[Building On Linux]]}}
  
== Download Xcode 3.x ==
+
== Instructions in mac/build.txt ==
  
To download Xcode, you will need to register at the Apple Developer site:
+
{{note|1=These instructions for building on mac are in [https://github.com/audacity/audacity/blob/master/mac/cmake_build.txt mac/cmake_build.txt in the Git repo].}}
  
:http://developer.apple.com
+
<pre>
 +
Instructions for building on macOS using CMake.
  
Once registered, the available downloads are located here:
+
Building on macOS has been made much simpler with the Audacity 2.4.0
 +
release. Still, read this document throughly before starting.
  
:http://developer.apple.com/downloads
+
1) Get and install the latest Xcode version available your macOS version:
  
Xcode 3.2.6 is the last version that officially supports the PPC architecture and the macosx10.4u SDK. Unless you're building release versions, the PPC support isn't absolutely necessary, but the SDK is required.
+
      MacOS                  Xcode Version (as of Mar 2020)
 +
      Catalina - 10.15        11.3
 +
      Mojave - 10.14          10.3
 +
      High Sierra - 10.13    9.4.1
 +
      Sierra - 10.12          9.2
 +
      El Capitan - 10.11      8.2.1
 +
      Yosemite - 10.10        7.2.1
  
If you are running Leopard, then enter "Xcode 3.1.4" in the search box on the left, press enter, and download the "Xcode 3.1.4 Developer DVD" dmg.
+
2) Clone the Audacity repository:
  
If you are running Snow Leopard or newer, enter “Xcode 3.2.6” in the search box on the left, press enter, and download the “Xcode 3.2.6 and iOS SDK 4.3” dmg:
+
      git clone https://github.com/audacity/audacity
  
:[[File:Bom xcode 326 download.png|780px]]
+
3) Clone wxWidgets 3.1.3:
  
== Download Xcode 4.5.2 ==
+
      git clone --recurse-submodules https://github.com/audacity/wxWidgets.git
  
Snow Leopard users should skip this step.
+
  Ensure that you clone with the "--recurse-submodules" option, and do not
 +
  just download the Zip package, otherwise there will be required components
 +
  missing.
  
NOTE:  You may choose to install other versions of Xcode, but at the time this guide was written, 4.5.2 was the latest and other versions may not work as outlined here.
+
  Don't be tempted to use wxWidgets already installed by a package manager
 +
  such as Homebrew because this will cause problems.
  
Enter “Xcode 4.5.2” in the search box on the left, press enter, and download the “Xcode 4.5.2” dmg:
+
  We have applied some Audacity specific patches to wxWidgets to better
 +
  support VoiceOver, so please use the audacity-fixes-3.1.3 branch. It's
 +
  the default branch on our GitHub copy:
  
:[[File:Bom xcode 452 download.png|780px]]
+
      https://github.com/audacity/wxWidgets/tree/audacity-fixes-3.1.3
  
Enter “Command Line Tools” in the search box on the left ("try "command" if you get no results), press enter and download the latest “Command Line Tools” dmg that corresponds to your version of OS X:
+
  You can be certain the correct branch is active with:
  
:[[File:Bom tools 452 download.png|780px]]
+
      git checkout audacity-fixes-3.1.3
  
 +
4) Change directory to the folder where wxWidgets was cloned and build it using:
  
== Download wxWidgets ==
+
      sudo <path to Audacity source>/mac/scripts/build_wxwidgets
  
You must download the wxMac version 2.8.12 of wxWidgets from:
+
5) The config command should return "3.1.3" if the install was successful:
  
:http://www.wxwidgets.org/downloads/
+
      /usr/local/x86_64/bin/wx-config --version
  
[[File:Bom wxwidgets 2812 download.png|780px]]
+
6) Now that you have wxWidgets installed, edit your ~/.bash_profile or
 +
  ~/.zprofile and add:
  
Download the "[[Media:Build wxwidgets.gz|Build wxwidgets.gz]]" script that will be used to build wxWidgets for use with Audacity.  Make sure you save the file as "build_wxwidgets.gz".  Safari will automatically uncompress the file, others may not.
+
      export WX_CONFIG=/usr/local/x86_64/bin/wx-config
  
 +
  Log out and back in again (or reboot) for this to take effect.
  
== Download cmake ==
+
7) Download the CMake 3.16.4 DMG from:
  
Download the latest Unix/Linux source version of cmake from:
+
      https://cmake.org/download
  
:http://www.cmake.org/cmake/resources/software.html
+
8) Double click the DMG, follow the prompts and drag the CMake app to the
 +
  Applications folder.
  
[[File:Bom cmake download.png|780px]]
+
  If you will be building from the command line, open the CMake application
 +
  and click the "Tools -> How to Install For Command Line Use" menu. It will
 +
  give you additional instructions on making CMake available to the command
 +
  line.
  
 +
  You are now ready to start building Audacity.
  
== Download pkg-config ==
+
BUILDING USING THE CMAKE GUI
  
Download the latest version of pkg-config from:
+
  NOTE: Building with the GUI interface will result in the downloading of
 +
        another copy of wxWidgets from Audacity.
  
:http://pkgconfig.freedesktop.org/releases/
+
1) Open the app.
  
[[File:Bom pkg-config download.png|780px]]
+
2) Click the "Browse Source..." button and locate the top of your Audacity
 +
  source tree, then click the "Open" button.
  
 +
3) Click the "Browse Build..." button and find the location where you want to
 +
  put the build (use the "New Folder" button at the bottom left to create a
 +
  new folder).
  
== Install Xcode 3.x ==
+
  This folder does not have to be in or even near the source tree, but it
 +
  must not be the same as the source tree. However, it is common to make it
 +
  a subdirectory of the Audacity source tree.
  
Locate the previously downloaded Xcode 3.x dmg on your system and double click it to have Finder verify and mount it:
+
4) Click the "Configure" button and when the dialog pops up, select "Xcode" for
 +
  the generator, then click the "Done" button.
  
[[File:Bom xcode 326 mount.png|center|480px]]
+
5) Click the "Generate" button to create the Xcode project.
  
The Xcode 3.2.6 installer checks the version of OS X that is currently running and that check will not succeed on versions above Snow Leopard. However the version check can be bypassed by starting the installation from the command-line.
+
6) Now you can either click the "Open Project" button or go to your "Build" folder in
{{note|It is advisable to have all OS X updates applied to your system before installing Xcode 3.x.  This is especially important for Lion users otherwise the installation will fail.}}
+
  Finder and open the Xcode project as normal.
{{advice|On Lion and Mountain Lion, the "Security & Privacy" section of System Preferences must be temporarily set to allow applications downloaded from "Anywhere", or Gatekeeper will prevent the package being opened.}} 
 
  
Open a Terminal window and start the installation by entering the following commands:
+
BUILDING FROM THE COMMAND LINE
  
For Leopard:
+
1) Change directory to your Audacity source tree.
  
:open "/Volumes/Xcode Tools/XcodeTools.mpkg"
+
      cd audacity
  
For Snow Leopard or newer:
+
2) Create the "build" folder (name it anything you like):
  
:export COMMAND_LINE_INSTALL=1
+
      mkdir bld
:open "/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg"
 
  
[[File:Bom xcode 326 install.png|780px]]
+
3) Change to the "build" folder:
  
This will start the installation while bypassing the version check.
+
      cd bld
  
On Mountain Lion, the installer needs to restart itself:
+
4) Configure and generate the Xcode project:
  
[[File:Bom xcode 326 restart.png|780px]]
+
      cmake -G Xcode ..
  
And, since the Xcode 3.2.6 certificate has expired, you will be asked to accept it:
+
5) Build Audacity using the CMake command or xcodebuild:
  
[[File:Bom xcode 326 cert.png|780px]]
+
      cmake --build . --config Release
  
You will then get to the normal installation process:
+
      xcodebuild --configuration Release
  
[[File:Bom xcode 326 installer.png|780px]]
+
  The "Audacity.app" bundle will be in the "bin/Release" subdirectory of your
 +
  "build" folder, so you can start it via Finder or:
  
Proceed through the various installation pages until you get to the “Custom Install” page:
+
      open bin/Release/Audacity.app
  
[[File:Bom xcode 326 custom install.png|780px]]
+
Notes:
  
Open the Essentials item by clicking the arrow:
+
  - If you'd like to get a completely clean build, just delete "build" folder
 +
    and return to step 2 above.
  
[[File:Bom xcode 326 options.png|780px]]
+
  - Once the Xcode project is generated, you shouldn't have to "configure" or
 +
    "generate" again as it will be done for you automatically after pulling
 +
    updates and building.
  
The minimum required options are “Unix Development” and “Mac OS X 10.4 SDK”, but if you're running Snow Leopard, you may elect to install everything.  On Lion or above, you will not be able to use “System Tools” and may choose to use the “iOS SDK” and “Documentation” from Xcode 4.5.2:
+
    For example:
  
[[File:Bom xcode 326 selected options.png|780px]]
+
        cd <audacity> directory
 +
        git pull
 +
        cd bld
 +
        cmake --build . --config Release
  
Continue through the pages to start the installation.
+
  - Instructions on optional signing of DMGs, showing languages other than English,
 +
    and other useful information can be found on our wiki at:
 +
    http://wiki.audacityteam.org/wiki/Building_On_Mac
  
On Mountain Lion, you will be prompted to stop iTunes near the end of the installation:
+
</pre>
  
[[File:Bom xcode 326 itunes.png|center|480px]]
+
== CMake Build ==
  
To terminate the process and allow the installation to complete, open a Terminal window and enter:
+
<pre>
 +
1) Change directory to your Audacity source tree.
  
:sudo killall iTunesHelper
+
      cd audacity
[[File:Bom xcode 326 ituneshelper.png|780px]]
 
  
Close the installer when complete:
+
2) Create the "build" folder (name it anything you like):
  
[[File:Bom xcode 326 complete.png|780px]]
+
      mkdir bld
  
then eject the Xcode 3.x dmg.
+
3) Change to the "build" folder:
  
The first time you use Xcode you will be prompted to install Java if you do not have it installed already.  So, use Finder to navigate to the "/Developer/Applications" folder, by selecting "Go to folder" from the "Go" menu in Finder:
+
      cd bld
  
[[File:Bom audiacty_build_xcode_goto.png|center|480px]]
+
4) Configure and generate the Xcode project:
  
Enter "/Developer/Applications" for the path and click "Go":
+
      cmake -G Xcode ..
  
[[File:Bom audiacty_build_xcode_folder.png|780px]]
+
5) Build Audacity using the CMake command or xcodebuild:
  
Now double-click the "Xcode" application to start it:
+
      cmake --build . --config Release
  
[[File:Bom audiacty_build_xcode_start.png|780px]]
+
      xcodebuild --configuration Release
  
At this point you may prompted to install Java:
+
  The "Audacity.app" bundle will be in the "bin/Release" subdirectory of your
 +
  "build" folder, so you can start it via Finder or:
  
[[File:Bom audiacty_build_xcode_java.png|center|480px]]
+
      open bin/Release/Audacity.app
 +
</pre>
  
Wait for the installation to complete and quit Xcode.
+
== For a Release CMake build ==
  
This completes the Xcode 3.x installation.
+
Additionally:
  
== Install Xcode 4.5.2 ==
+
<pre>
Snow Leopard users should skip this step.
+
6) Add the help files
  
Locate the Xcode 4.5.2 dmg, xcode4520418508a.dmg, on your system and double click it to have Finder verify and mount it:
+
  Open contents of bin/Release/Audacity.app
 +
  Add in files with directory help/manual/ and then the 5 top level items
  
[[File:Bom xcode 452 mount.png|center|480px]]
+
7) Notarize Audacity
  
The Xcode folder will open when it's mounted:
+
  ../mac/scripts/build_dist.sh ../mac ../bld/bin/Release
 +
</pre>
  
[[File:Bom xcode 452 folder.png|780px]]
+
For Notarization to work, you'll need to have already jumped through the Apple hoops, and have set up your signing file.  There are two stages to notarization, one for the bundle, one for the dmg.
  
You may choose to drag the Xcode app to wherever you like, but this guide expects it to be located in the Applications folder:
+
To test the Notarization, upload the dmg to dropbox and then download it again.  Then double-click to
 +
install and drag across to /Applications. When you launch Audacity, you now get a warning about having downloaded from the internet, rather than being prevented from running...
  
[[File:Bom xcode 452 copy.png|780px]]
 
  
Locate the Command Line Tools dmg, xcode452cltools10_76938212a.dmg, on your system and double click it to have Finder verify and mount it:
+
== Optional Extras ==
  
[[File:Bom tools 452 mount.png|center|480px]]
+
{{tip|'''FFmpeg and LAME'''
 +
For these, see [[Building Extras on Mac]]}}
  
The Command Line Tools folder will open:
+
== Variations ==
  
[[File:Bom tools 452 folder.png|780px]]
+
{{note|1=These instructions for variations on building aren't in mac/build.txt in the Git repo.  They're actually mostly obsolete instructions.  The CMake building now takes care of the GitIdent and mod-script-pipe.  Languages should not be an issue if you are already set up with gettext.  The signing has been replaced by Notarization.  We no longer declutter the dmg, and no one has complained or commented about it on the forums.}}
  
Start the installation by double clicking the installer, “Command Line Tools (Lion).mpkg” in this case:
+
===Fetching The Manual===
  
[[File:Bom tools 452 installer.png|780px]]
+
We have [[Building The Manual|instructions for fetching the manual]] on another page.
  
Once the installation completes, close the installer:
 
  
[[File:Bom tools 452 complete.png|780px]]
+
===Defaulting to Portable Settings===
  
and you may eject the Command Line Tools .dmg.  
+
<pre>
 +
1. Within audacity.app/Contents add the directories:
 +
    Portable Settings
 +
    Portable Settings/AutoSave
  
In the Terminal window, enter:
+
2. Set permissions on these two directories to 777
 +
    chmod 777 "Portable Settings"
 +
    chmod 777 "Portable Settings/AutoSave"
 +
</pre>
  
:sudo xcode-select -switch "/Applications/Xcode.app/Contents/Developer"
+
These steps should of course be done before signing.
  
[[File:Bom xcode 452 switch.png|780px]]
+
== Official Full Releases==
  
You will be asked to enter your password:
+
Official Audacity full releases:
  
[[File:Bom xcode 452 switched.png|780px]]
+
* Have a GitIdent, visible in the about box build information, that says what branch was used in building.
 +
* Include a copy of the manual.
 +
* Include other languages.
 +
* Have a de-cluttered .dmg (the folders in it are dragged outside the visible area)
 +
* Are signed with a signing key.
  
To make it a little easier to use Xcode 3.2.6 from the command-line, create a link to the 3.2.6 version of xcodebuild.  You make change the "xcodebuild3" to whatever you like, just remember when building Audacity from the command-line to use what you specify here:
+
<s>
 +
===Updating GitIdent===
  
:sudo ln -s /Developer/usr/bin/xcodebuild /usr/bin/xcodebuild3
+
<pre>
 +
The Audacity "About" box can contain a link to the git commit at which
 +
Audacity was built. To create this, run this batch script in /mac/scripts/
 +
 +
  get_gitident.sh
 +
 +
If you do this, you are responsible for making sure the ident is correct
 +
in future builds.  The script overwrites RevisionIdent.h in the src directory.
 +
If you make further changes to your local copy after this step, or merge a
 +
more recent version from git, this file, and hence the ident in the build,
 +
stays the same, and so would be misleading.
 +
 +
To reset RevisionIdent.h you could do:
 +
 +
  git reset --hard origin/master
 +
</pre>
  
[[File:Bom xcode 452 xcodebuild3.png|780px]]
+
===Include mod-script-pipe===
  
This completes the Xcode 4.5.2 installation.
+
Build this within the Xcode project ON THE SAME DAY as you built audacity. You can click on the .so in the IDE to find out where Xcode put it (it will have some weird long temporary path).
  
 +
Just before code signing, add it in to the Audacity bundle, into a subdirectory called 'modules'.
 +
</s>
  
== Install cmake ==
+
===Include Languages===
  
In the Terminal window, extract the cmake archive if it was not extracted on download (modify the cmake version number in the command if needed):
 
  
:tar xf ~/Downloads/cmake-2.8.10.2.tar
+
{{alert|1=Beware!  Audacity needs a clean and then a recompile if it is to include languages.<br>
 +
For some reason yet to be investigated, incremental compiles will not include the language files in audacity.app.<br>
 +
''(Check by looking inside the app and looking in 'Resources')''}}
  
Now change to the directory of the extracted cmake:
+
<pre>
 +
If you need Audacity to show languages other than English, install the gettext
 +
suite of tools (to get the msgfmt command).  The source can be downloaded from:
  
:cd cmake-2.8.10.2
+
  ftp://ftp.gnu.org/gnu/gettext/gettext-latest.tar.gz
  
or if you had already extracted cmake:
+
Untar it:
  
:cd ~/Downloads/cmake-2.8.10.2
+
  tar xf gettext-latest.tar.gz
  
Configure cmake:
+
And install:
  
:./configure --prefix=/usr/local --docdir=/share/doc/CMake --mandir=/share/man
+
  cd gexttext-latest
 +
  ./configure
 +
  sudo make install
  
[[File:Bom cmake configure.png|780px]]
+
Then clean and recompile.
 +
Incremental compiles will NOT include the language files.
  
Build cmake:
+
</pre>
  
:make
+
<s>
 +
===Decluttering the dmg===
  
[[File:Bom cmake build.png|780px]]
+
<pre>
 +
1. Open the dmg
  
Install cmake:
+
2. Drag the right border wider.
  
:sudo make install
+
3. Drag all folders that should not be visible into that area.
  
[[File:Bom cmake install.png|780px]]
+
4. Drag right border narrower again.
 +
</pre>
  
This completes the cmake installation.
 
  
 +
===Signing the DMG===
  
== Install pkg-config ==
+
<pre>
 +
1) Comment out the last line of mac/scripts/build_dist.sh so that it reads
 +
 +
  #rm -rf ${DMG} TMP.dmg
 +
 +
  This will prevent deletion of TMP.dmg
  
As with cmake, use the Terminal to extract the pkg-config archive and change to the extracted directory:
+
2) Delete any previous /private/tmp/TMP.dmg and /private/tmp/Audacity.dst
 +
    (otherwise, the rebuilt plug-ins folder will contain an unnecessary duplicate
 +
    of itself).
  
:tar xf ~/Downloads/pkg-config-0.27.1.tar
+
    Then clean and build Audacity normally.
:cd pkg-config-0.27.1
+
 +
3) Navigate to /private/tmp/ and type
 +
 +
    hdiutil resize -size 200m TMP.dmg
 +
 +
    This step is needed as codesigning takes some temporary space, more than is
 +
    available in the dmg.
 +
 +
4) mount the dmg
 +
    hdiutil mount TMP.dmg
  
[[File:Bom pkgconfig extract.png|780px]]
+
4a) Not part of the signing, but a good idea to de-clutter the dmg
 +
    per instructions in the section above.
 +
 +
5) Codesign the app (deep to make sure everything important is signed)
 +
   
 +
    codesign --deep -s <identity> -v "/Volumes/Audacity 2.2.0/Audacity.app"
  
or if you already extracted pkg-config, change to that extracted directory:
+
    If you see errors like this, no matter what size you used in step (3):
:cd ~/Downloads/pkg-config-0.27.1
 
  
Now configure pkg-config:
+
        can't allocate code signature data for: /Volumes/Audacity 2.2.0/Audacity.app/Contents/MacOS/Audacity
 +
        (for architecture i386) because larger updated load commands do not fit (the program must be relinked
 +
        using a larger -headerpad value)
  
:sh configure --with-internal-glib
+
    Then in the XCode project, add -headerpad_max_install_names to Other Linker flags (OTHER_LDFLAGS)
 +
    for Release configuration of the Audacity target, and go back to step (2).
 +
 +
6) Check it is signed to gatekeeper's satisfaction:
 +
 +
    spctl -a -v "/Volumes/Audacity 2.2.0/Audacity.app"
 +
 +
7) unmount the dmg
  
[[File:Bom pkgconfig configure.png|780px]]
+
    hdiutil eject "/Volumes/Audacity 2.2.0"
 +
 +
8) Make a compressed dmg
 +
 +
    hdiutil convert TMP.dmg -format UDZO -imagekey zlib-level=9 -o "Newname.dmg"
 +
 +
9) codesign that
 +
 +
    codesign -s <identity> -v Newname.dmg
 +
</pre>
 +
</s>
  
and build pkg-config:
 
  
:make
 
 
[[File:Bom pkgconfig build.png|780px]]
 
 
Install pkg-config:
 
 
:sudo make install
 
 
[[File:Bom pkgconfig install.png|780px]]
 
 
This completes the pkg-config installation.
 
 
 
== Install wxWidgets ==
 
 
In the Terminal, extract the wxWidgets source if not already extracted:
 
 
:tar xf ~/Downloads/wxMac-2.8.12.tar
 
 
[[File:Bom wxwidgets 2812 extract.png|780px]]
 
 
Change to the extracted directory:
 
 
:cd wxMac-2.8.12
 
 
:or:
 
 
:cd ~/Downloads/wxMac-2.8.12
 
 
[[File:Bom wxwidgets 2812 cd.png|780px]]
 
 
Start the build.  This assumes you downloaded the build_wxwidgets script to your Downloads directory:
 
 
:sh ~/Downloads/build_wxwidgets
 
 
[[File:Bom wxwidgets 2812 build.png|780px]]
 
 
After all configurations are built, you will be prompted for your password. Watch the build for the password prompt, because if the requests for a password time out, you'll have to build again:
 
 
[[File:Bom wxwidgets 2812 install.png|780px]]
 
 
All configurations have been built and installed:
 
~/Downloads/wxMac-2.8.12
 
~/Downloads/wxMac-2.8.12/bld_release_shared ~/Downloads/wxMac-2.8.12
 
 
[[File:Bom wxwidgets 2812 complete.png|780px]]
 
 
To verify, list the installed configurations:
 
 
:wx-config --list
 
[[File:Bom wxwidgets 2812 list.png|780px]]
 
 
Make sure you see 1 default configuration (mac-unicode-release-2.8)
 
and 3 alternates:
 
 
[[File:Bom wxwidgets 2812 installed.png|780px]]
 
 
wxWidgets installation is now complete.
 
 
 
== Create links ==
 
To make it easier for Xcode to find the cmake, pkg-config, and wx-config, create links to them in the Xcode developer tree:
 
 
:sudo ln -s /usr/local/bin/pkg-config /Developer/usr/bin
 
:sudo ln -s /usr/local/bin/cmake /Developer/usr/bin
 
:sudo ln -s /usr/local/bin/wx-config /Developer/usr/bin
 
 
[[File:Bom create links.png|780px]]
 
 
 
== Download Audacity ==
 
 
Now that everything is in place, we finally get to the whole purpose of this exercise, building Audacity.  But first, you must decide if you want to use the tarball or tagged source which gives you the current release of Audacity, or if you want to get the absolute latest development source (SVN HEAD).
 
{{advice|Remember that occasionally, SVN HEAD may not build becaue of development in progress, or if it does, there may be bugs.}}
 
 
Make your choice when downloading from here:
 
 
:http://audacity.sourceforge.net/download/source
 
 
[[File:Bom audiacty_build_download.png|780px]]
 
 
Once you have the source downloaded and extracted, you may use either the xcodebuild command-line utility or the Xcode 3.2.6 IDE.
 
 
The Audacity xcode project has four configurations defined:
 
 
:Debug Static - disables optimization, enables debugging code, and links to static libraries
 
:Debug Shared - disables optimization, enables debugging code, and links to shared libraries
 
:Release Static - enables optimization, disables debugging code, and links to static libraries
 
:Release Shared - disables optimization, disables debugging code, and links to shared libraries
 
 
So you'll need to select which one you want to use in the following steps, but "Debug Static" will be used for this guide.
 
 
 
== Build with xcodebuild ==
 
 
To use the command-line utility, open a Terminal window, change to the Audacity mac directory, and start the build.  If you didn't install Xcode 4.5.2 above, then use "xcodebuild" here in place of "xcodebuild3":
 
 
:cd audacity/mac
 
:xcodebuild3 -configuration "Debug Static"
 
 
[[File:Bom audiacty_build_xcodebuild.png|780px]]
 
 
When it completes, you should get a "Build Succeeded" message:
 
 
[[File:Bom audiacty_build_xcodebuild_complete.png|780px]]
 
 
The newly built Audacity can be started from Finder, using gdb, or simply:
 
 
:open "build/Debug Static/Audacity.app"
 
 
[[File:Bom audiacty_build_xcodebuild_open.png|780px]]
 
 
 
== Build with Xcode IDE ==
 
 
To build Audacity using the Xcode 3.2.6 IDE, use Finder to navigate to the "/Developer/Applications" folder, by selecting "Go to folder" from the "Go" menu in Finder:
 
 
[[File:Bom audiacty_build_xcode_goto.png|center|480px]]
 
 
Enter "/Developer/Applications" for the path and click "Go":
 
 
[[File:Bom audiacty_build_xcode_folder.png|780px]]
 
 
Now double-click the "Xcode" application to start it:
 
 
[[File:Bom audiacty_build_xcode_start.png|780px]]
 
 
Open the Audacity Xcode project by selecting "Open" from the "File" menu in Xcode:
 
 
[[File:Bom audiacty_build_xcode_open.png|center|480px]]
 
 
Navigate to the "audacity/mac" folder and then double-click the "Audacity.xcodeproj" project:
 
 
[[File:Bom audiacty_build_xcode_xcodeproj.png|780px]]
 
 
Now choose the configuration required from the menu top left (underneath the window buttons), then click "Build and Run" on the toolbar. A freshly built Audacity will start when the build completes.
 
 
[[File:Bom audiacty_build_xcode_build.png|780px]]
 
  
 
[[Category:Mac Platform]] [[Category:For Developers]]
 
[[Category:Mac Platform]] [[Category:For Developers]]

Latest revision as of 11:54, 19 August 2021

Warning icon This page has been deprecated. Newer information can be found here: https://github.com/audacity/audacity/blob/master/BUILDING.md
The information on this page are likely out-of-date and will not be updated in the forseeable future. It may be removed at any time.
ToDo-2 Add
  • Instructions for building modules
These are instructions for building on Mac

The build family of pages:

Instructions in mac/build.txt

These instructions for building on mac are in mac/cmake_build.txt in the Git repo.
Instructions for building on macOS using CMake.

Building on macOS has been made much simpler with the Audacity 2.4.0
release. Still, read this document throughly before starting.

1) Get and install the latest Xcode version available your macOS version:

      MacOS                   Xcode Version (as of Mar 2020)
      Catalina - 10.15        11.3
      Mojave - 10.14          10.3
      High Sierra - 10.13     9.4.1
      Sierra - 10.12          9.2
      El Capitan - 10.11      8.2.1
      Yosemite - 10.10        7.2.1

2) Clone the Audacity repository:

      git clone https://github.com/audacity/audacity

3) Clone wxWidgets 3.1.3:

      git clone --recurse-submodules https://github.com/audacity/wxWidgets.git

   Ensure that you clone with the "--recurse-submodules" option, and do not
   just download the Zip package, otherwise there will be required components
   missing.

   Don't be tempted to use wxWidgets already installed by a package manager
   such as Homebrew because this will cause problems.

   We have applied some Audacity specific patches to wxWidgets to better 
   support VoiceOver, so please use the audacity-fixes-3.1.3 branch. It's
   the default branch on our GitHub copy:

      https://github.com/audacity/wxWidgets/tree/audacity-fixes-3.1.3

   You can be certain the correct branch is active with:

      git checkout audacity-fixes-3.1.3

4) Change directory to the folder where wxWidgets was cloned and build it using:

      sudo <path to Audacity source>/mac/scripts/build_wxwidgets

5) The config command should return "3.1.3" if the install was successful:

      /usr/local/x86_64/bin/wx-config --version

6) Now that you have wxWidgets installed, edit your ~/.bash_profile or
   ~/.zprofile and add:

      export WX_CONFIG=/usr/local/x86_64/bin/wx-config

   Log out and back in again (or reboot) for this to take effect.

7) Download the CMake 3.16.4 DMG from:

      https://cmake.org/download

8) Double click the DMG, follow the prompts and drag the CMake app to the
   Applications folder.

   If you will be building from the command line, open the CMake application
   and click the "Tools -> How to Install For Command Line Use" menu. It will
   give you additional instructions on making CMake available to the command
   line.

   You are now ready to start building Audacity.

BUILDING USING THE CMAKE GUI

   NOTE: Building with the GUI interface will result in the downloading of
         another copy of wxWidgets from Audacity.

1) Open the app.

2) Click the "Browse Source..." button and locate the top of your Audacity
   source tree, then click the "Open" button.

3) Click the "Browse Build..." button and find the location where you want to
   put the build (use the "New Folder" button at the bottom left to create a
   new folder).

   This folder does not have to be in or even near the source tree, but it
   must not be the same as the source tree. However, it is common to make it
   a subdirectory of the Audacity source tree.

4) Click the "Configure" button and when the dialog pops up, select "Xcode" for
   the generator, then click the "Done" button.

5) Click the "Generate" button to create the Xcode project.

6) Now you can either click the "Open Project" button or go to your "Build" folder in
   Finder and open the Xcode project as normal.

BUILDING FROM THE COMMAND LINE

1) Change directory to your Audacity source tree.

      cd audacity

2) Create the "build" folder (name it anything you like):

      mkdir bld

3) Change to the "build" folder:

      cd bld

4) Configure and generate the Xcode project:

      cmake -G Xcode ..

5) Build Audacity using the CMake command or xcodebuild:

      cmake --build . --config Release

      xcodebuild --configuration Release

   The "Audacity.app" bundle will be in the "bin/Release" subdirectory of your
   "build" folder, so you can start it via Finder or:

      open bin/Release/Audacity.app

Notes:

   - If you'd like to get a completely clean build, just delete "build" folder
     and return to step 2 above.

   - Once the Xcode project is generated, you shouldn't have to "configure" or
     "generate" again as it will be done for you automatically after pulling
     updates and building.

     For example:

        cd <audacity> directory
        git pull
        cd bld
        cmake --build . --config Release

   - Instructions on optional signing of DMGs, showing languages other than English,
     and other useful information can be found on our wiki at: 
     http://wiki.audacityteam.org/wiki/Building_On_Mac

CMake Build

1) Change directory to your Audacity source tree.

      cd audacity

2) Create the "build" folder (name it anything you like):

      mkdir bld

3) Change to the "build" folder:

      cd bld

4) Configure and generate the Xcode project:

      cmake -G Xcode ..

5) Build Audacity using the CMake command or xcodebuild:

      cmake --build . --config Release

      xcodebuild --configuration Release

   The "Audacity.app" bundle will be in the "bin/Release" subdirectory of your
   "build" folder, so you can start it via Finder or:

      open bin/Release/Audacity.app

For a Release CMake build

Additionally:

6) Add the help files

   Open contents of bin/Release/Audacity.app
   Add in files with directory help/manual/ and then the 5 top level items

7) Notarize Audacity

   ../mac/scripts/build_dist.sh ../mac ../bld/bin/Release

For Notarization to work, you'll need to have already jumped through the Apple hoops, and have set up your signing file. There are two stages to notarization, one for the bundle, one for the dmg.

To test the Notarization, upload the dmg to dropbox and then download it again. Then double-click to install and drag across to /Applications. When you launch Audacity, you now get a warning about having downloaded from the internet, rather than being prevented from running...


Optional Extras

Bulb icon FFmpeg and LAME

For these, see Building Extras on Mac

Variations

These instructions for variations on building aren't in mac/build.txt in the Git repo. They're actually mostly obsolete instructions. The CMake building now takes care of the GitIdent and mod-script-pipe. Languages should not be an issue if you are already set up with gettext. The signing has been replaced by Notarization. We no longer declutter the dmg, and no one has complained or commented about it on the forums.

Fetching The Manual

We have instructions for fetching the manual on another page.


Defaulting to Portable Settings

 1. Within audacity.app/Contents add the directories:
    Portable Settings
    Portable Settings/AutoSave

 2. Set permissions on these two directories to 777
    chmod 777 "Portable Settings"
    chmod 777 "Portable Settings/AutoSave"

These steps should of course be done before signing.

Official Full Releases

Official Audacity full releases:

  • Have a GitIdent, visible in the about box build information, that says what branch was used in building.
  • Include a copy of the manual.
  • Include other languages.
  • Have a de-cluttered .dmg (the folders in it are dragged outside the visible area)
  • Are signed with a signing key.

Updating GitIdent

 The Audacity "About" box can contain a link to the git commit at which 
 Audacity was built. To create this, run this batch script in /mac/scripts/
 
   get_gitident.sh
 
 If you do this, you are responsible for making sure the ident is correct
 in future builds.  The script overwrites RevisionIdent.h in the src directory.
 If you make further changes to your local copy after this step, or merge a
 more recent version from git, this file, and hence the ident in the build, 
 stays the same, and so would be misleading.
 
 To reset RevisionIdent.h you could do:
 
   git reset --hard origin/master

Include mod-script-pipe

Build this within the Xcode project ON THE SAME DAY as you built audacity. You can click on the .so in the IDE to find out where Xcode put it (it will have some weird long temporary path).

Just before code signing, add it in to the Audacity bundle, into a subdirectory called 'modules'.

Include Languages

Warning icon Beware! Audacity needs a clean and then a recompile if it is to include languages.

For some reason yet to be investigated, incremental compiles will not include the language files in audacity.app.
(Check by looking inside the app and looking in 'Resources')

If you need Audacity to show languages other than English, install the gettext
suite of tools (to get the msgfmt command).  The source can be downloaded from:

   ftp://ftp.gnu.org/gnu/gettext/gettext-latest.tar.gz

Untar it:

   tar xf gettext-latest.tar.gz

And install:

   cd gexttext-latest
   ./configure
   sudo make install

Then clean and recompile.
Incremental compiles will NOT include the language files.

Decluttering the dmg

 1. Open the dmg

 2. Drag the right border wider.

 3. Drag all folders that should not be visible into that area.

 4. Drag right border narrower again.


Signing the DMG

 1) Comment out the last line of mac/scripts/build_dist.sh so that it reads
 
   #rm -rf ${DMG} TMP.dmg
 
   This will prevent deletion of TMP.dmg

 2) Delete any previous /private/tmp/TMP.dmg and /private/tmp/Audacity.dst
    (otherwise, the rebuilt plug-ins folder will contain an unnecessary duplicate
    of itself).

    Then clean and build Audacity normally.
 
 3) Navigate to /private/tmp/ and type 
 
    hdiutil resize -size 200m TMP.dmg
 
    This step is needed as codesigning takes some temporary space, more than is 
    available in the dmg.
 
 4) mount the dmg
    hdiutil mount TMP.dmg

 4a) Not part of the signing, but a good idea to de-clutter the dmg
    per instructions in the section above.
 
 5) Codesign the app (deep to make sure everything important is signed)
     
    codesign --deep -s <identity> -v "/Volumes/Audacity 2.2.0/Audacity.app"

    If you see errors like this, no matter what size you used in step (3):

        can't allocate code signature data for: /Volumes/Audacity 2.2.0/Audacity.app/Contents/MacOS/Audacity
        (for architecture i386) because larger updated load commands do not fit (the program must be relinked
        using a larger -headerpad value)

    Then in the XCode project, add -headerpad_max_install_names to Other Linker flags (OTHER_LDFLAGS)
    for Release configuration of the Audacity target, and go back to step (2).
 
 6) Check it is signed to gatekeeper's satisfaction:
 
    spctl -a -v "/Volumes/Audacity 2.2.0/Audacity.app"
 
 7) unmount the dmg

    hdiutil eject "/Volumes/Audacity 2.2.0"
 
 8) Make a compressed dmg
 
    hdiutil convert TMP.dmg -format UDZO -imagekey zlib-level=9 -o "Newname.dmg"
 
 9) codesign that
 
    codesign -s <identity> -v Newname.dmg