Difference between revisions of "Developing On Mac"

From Audacity Wiki
Jump to: navigation, search
(adding --enable-debug flag to wxmac build instructions)
(Alert.)
 
(28 intermediate revisions by 6 users not shown)
Line 1: Line 1:
'''Related Pages:'''
+
{{alert|1=This article is now largely of historical interest only. See [[Building On Mac]] instead.
 +
* This page explains the general principles of building a universal binary of Audacity on Mac from SVN and the issues and solutions doing so up to 2012/early 2013.
 +
 
 +
If you still need help after reading [[Building On Mac]], please ask on the [https://forum.audacityteam.org/viewforum.php?f=19 Compiling Audacity] section of our [https://forum.audacityteam.org Forum].}}
 +
<div style="margin:24px">
 +
'''Related article(s):'''
 +
* [[Release_Process/Mac|Release Process/Mac]] Steps to make a universal binary of Audacity for '''public release'''
 +
* [[Developing On Linux]]
 
* [[Developing On Windows]]
 
* [[Developing On Windows]]
* [[Developing On Linux]]
+
* [[Developer Guide]]
 
+
</div>
----
+
 
+
==Prerequisites==
 
+
You will need pkgconfig installed.  By default this is not on your mac, but if you use fink or macports you may already have it in /sw/bin or /opt/bin.  If you don't have it, you'll need to install [http://www.finkproject.org/download/index.php?phpLang=en fink].  Then you can get it using fink with the command {{Codelist|fink install pkgconfig}}
= Compiling on Mac OS X =
+
Alternatively you can use [http://www.macports.org/ macports] to install it.
  
==General==
+
[https://wiki.audacityteam.org/wiki/Developing_On_Linux_Under_Windows#Get_Audacity_from_the_SVN_repository Get Audacity from the SVN repository].
While the 1.3.4 code will build, it will crash due to problems in AudioIO.cpp. Build from the {{external|[http://audacity.sourceforge.net/community/developers#cvs latest CVS development code]}} instead, where this problem is fixed.
 
  
Read the instructions in "compile.txt" in the "Mac" subdirectory of the source tree. Compile at the command-line, or use the Xcode project file. The latest Xcode project file in CVS is OK. The one tagged as "1_3_4" in CVS is rather broken and is missing a few source files and the whole of libvamp.  
+
==Building Universal Binary==
 +
Generally it was easier to build a native PPC or Intel version than a Universal Binary needed for public releases of Audacity.  
  
Compile just as you would a Unix program (see [[Developing On Linux|here]]). After building "audacity", an additional step is performed, that creates "Audacity.app". Make sure that you run "Audacity.app" and not "audacity", otherwise it won't work.
+
=== Instructions at June 2010===
 +
These instructions were copied from an email on audacity-devel in June 2010.
 +
<ol>
 +
<li>{{code|svn checkout <nowiki>http://audacity.googlecode.com/svn/audacity-src/trunk/</nowiki> audacity}}
 +
<li>{{code|cd audacity/mac}}
 +
<li>{{code|1=xcodebuild -target Audacity -configuration "Release Static" WX_PREFIX=<location of wxMac>}}
 +
Building with a shared wxMac is possible but is not really worth the extra trouble required.
 +
{{hint|wxMac needs patching to work properly with Audacity (a few bug fixes). The patches are found in the mac directory of the Audacity sources.}}
 +
<li>If Audacity fails to build due to missing configure macros you will need to add a file called "dirlist" to /usr/share/aclocal (dirlist should contain a list of extra places to check for m4 macros, one per line)
 +
<li>Add the directory containing you pkg-config m4 macros - should be something like<br>{{path|/PATH PKG-CONFIG INSTALLED TO/share/aclocal}}
 +
<li>If you wish to use Xcode to build Audacity in a GUI environment, add any configuration, like WX_PREFIX, to the relevant .xcconfig file.  There are four, one for each build setting.
 +
</ol>
  
==wxWidgets==
+
=== Working scenario building Universal Binary on PPC or Intel Mac OS X 10.5 ===
wxMac is the version of wxWidgets for Mac OS.  
+
The following scenario was reported to build from SVN HEAD as a Universal Binary on both Power PC and Intel Mac on OS X 10.5.1, using Xcode 3 and either wxWidgets 2.6.4 or 2.8.11, or the OS X 10.5.1 wxWidgets shared library.  
  
* Audacity 1.2.x / wxWidgets 2.4 ONLY: In the "mac" directory there is a patch file for wxMac-2.4.0 - it's recommended that you apply this patch first.  This enables support for custom cursors, allows disabling anti-aliased text (for speed), and fixes a couple of bugs.
+
Note that if you used OS X 10.6 Snow Leopard or later there were likely to be various problems.
*Audacity 1.3.0 through 1.3.5 / wxWidgets 2.6 ONLY: These beta builds used wxWidgets 2.6 and will only build using 2.6.
+
* For Snow Leopard you could read [https://forum.audacityteam.org/viewtopic.php?f=19&t=52237 this Forum topic]  which offered a special shell script to build wxMac. This was reported viable as at January 2011.
*Audacity 1.3.6 or greater / wxWidgets 2.8.9 or greater: There were 2 significant bug fixes in wxWidgets 2.8.9 upon which Audacity versions starting with 1.3.6 depend.
+
* Xcode 4 no longer supports SDKs 10.4/10.5 and GCC 4.0 (or PPC for GCC 4.2). You could however use parallel Xcode 3 and Xcode 4 installations as in "[http://hints.macworld.com/article.php?story=20110318050811544 Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4 Apps]" on the Mac OS X hints site.
  
==Latest position building from CVS HEAD==  
+
====General Principles====  
 
+
:1 Setup wxWidgets
Generally it seems easier to build a native PPC or Intel version than a Universal Binary. This scenario is reported to build from CVS HEAD as a Universal Binary on both Power PC and Intel Mac on OS X 10.5.1, using Xcode 3 and either wxWidgets 2.6.4 or 2.8.10, or the OS X 10.5.1 wxWidgets shared library.  The general principles are:
+
:1.1 -Create a wx directory in your audacity directory.  For example:  $HOME/audacity/wx
#Create a wx directory in your audacity directory.  For example:  $HOME/audacity/wx
+
:1.2 -If for some reason you are using wxMac 2.8.10, Patch the wxMac2.8.10 by doing the following
#Patch the wxMac2.8.10 bz doing the following
 
 
{{Codelist|cd /path/to/wxMac-2.8.10<br>
 
{{Codelist|cd /path/to/wxMac-2.8.10<br>
 
patch -p1 < /path/to/audacityrepos/mac/wxMac-2.8.10.patch<br>
 
patch -p1 < /path/to/audacityrepos/mac/wxMac-2.8.10.patch<br>
 
}}
 
}}
#Build wxWidgets from the command line. Make a build directory inside the wxWidgets directory and from there run (without the line breaks):
+
:1.3 -Build wxWidgets from the command line. Make a build directory inside the wxWidgets directory and from there run (without the line breaks):
 
{{Codelist|<nowiki> ../configure --disable-shared --enable-universal_binary</nowiki><br><nowiki>
 
{{Codelist|<nowiki> ../configure --disable-shared --enable-universal_binary</nowiki><br><nowiki>
 
--prefix=/path/to/audacity-beta/wx/ --enable-static --enable-unicode</nowiki>&nbsp;<br><nowiki>
 
--prefix=/path/to/audacity-beta/wx/ --enable-static --enable-unicode</nowiki>&nbsp;<br><nowiki>
Line 38: Line 55:
 
# in utils/wxrc/Makefile add <i>'''-mmacosx-version-min=10.4'''</i>&nbsp; to the CXX = g++ line (25)
 
# in utils/wxrc/Makefile add <i>'''-mmacosx-version-min=10.4'''</i>&nbsp; to the CXX = g++ line (25)
 
# change the <nowiki>#</nowiki>define of ICONV_CHAR_CAST in src/common/strconv.cpp to: <br><i><b><nowiki>#define ICONV_CHAR_CAST(x) ((const char **)(x))</nowiki></b></i>}}<br>
 
# change the <nowiki>#</nowiki>define of ICONV_CHAR_CAST in src/common/strconv.cpp to: <br><i><b><nowiki>#define ICONV_CHAR_CAST(x) ((const char **)(x))</nowiki></b></i>}}<br>
:2. Do make followed by make install.
+
:2. Do make followed by make install (by typing 'make', then 'make install'. If you have the wx-prefix outside of your home directory you may need 'sudo make install' instead, which will prompt you for a password.)
 
:3. Open the audacity.xcodeproj file.  You should create a text file called Debug_Static.xcconfig in the same directory as the project file, and add the line to this text file to include the path you specified as --prefix when building wxMac.  For example 'WXPREFIX = /path/to/audacity/wx'.
 
:3. Open the audacity.xcodeproj file.  You should create a text file called Debug_Static.xcconfig in the same directory as the project file, and add the line to this text file to include the path you specified as --prefix when building wxMac.  For example 'WXPREFIX = /path/to/audacity/wx'.
:3.5. If you get an error saying that pkg-config is required, you need to add the path of pkg-config on your system to the XCode settings by adding the line 'PATH = /sw/bin:$PATH' to the .xcconfig file (in the project's XCode settings folder.  It may also be in /opt/bin if you use macports vs fink.
+
:3.5. If you get an error saying that pkg-config is required, you need to add the path of pkg-config on your system to the XCode settings by adding the line 'PATH = /sw/bin:$PATH' (if you use fink) to the .xcconfig file (in the project's XCode settings folder.  It may also be in /opt/bin if you use macports vs fink.
 +
 
 +
:4. Compile Audacity using Xcode. Open the latest Xcode project file and update it if required. In the list of targets do a "Get Info" on Audacity and Configure. You may need to change a few "User-Defined" settings. Most of the Wx ones need changing to which version of wxWidgets you've chosen and the path that you set above in --prefix when building it. You may have to change the CONFIG_STATIC and CONFIG_UNICODE in Configure. Most of the settings required for these variables can be gained from running wx-config --libs, --ld or --cflags.  Also note that if using OS X 10.6 you may have to set xcode to use gcc 4.0 instead of 4.2 in your project settings.
 +
:4.1 If you get an error related to libflac, you have libflac installed to /usr/local/lib, and Audacity is linking to this instead of the libflac that the project builds.  To workaround this, rename /usr/local/lib/libFLAC.dylib and libFLAC++.dylib to something else.  A more proper workaround would be changing the include and linker paths to remove /usr/local/lib.
 +
 
 +
==== Troubleshooting tips ====
 +
<ul><li> Install pkg-config and make sure it's in your path; If it's not in your path Xcode won't find it and nothing will build
 +
<li> Ensure that you have wxMac installed and that you know where it is - you can use the libraries that Apple provide but they're old and not great
 +
<li> Do not try and build Audacity from the configure script, because you won't get a fully working universal binary - use the Xcode project instead. Open the Xcode project either from the command line or via the Finder.
 +
<li>If wxMac is not installed to /usr/local you will have to set it up yourself. Either open Xcode like this:
 +
{{codelist|1=xcodebuild -target Audacity -configuration "Release Static" WX_PREFIX=/path/wxMac/installed/to}} or set it in xcode via the appropriate .xcconfig file or the WX_PREFIX variable in the project
 +
<li> If Audacity fails to build due to missing configure macros you will need to add a file called "dirlist" to /usr/share/aclocal . The dirlist should contain a list of extra places to check for m4 macros, one per line. Add the directory containing you pkg-config m4 macros - it should be something like:
 +
{{codelist| /PATH PKG-CONFIG INSTALLED TO/share/aclocal}} </ul><br>
 +
== Even older information ==
 +
 
 +
=== For wxWidgets 2.6.x ===
  
:4. Compile Audacity 1.3.4 using Xcode. Open the latest Xcode project file and update it if required. In the list of targets do a "Get Info" on Audacity and Configure. You may need to change a few "User-Defined" settings. Most of the Wx ones need changing to which version of wxWidgets you've chosen and the path that you set above in --prefix when building it. You may have to change the CONFIG_STATIC and CONFIG_UNICODE in Configure. Most of the settings required for these variables can be gained from running wx-config --libs, --ld or --cflags.  
+
<ol>
 +
<li> add <i>'''--with-expat=builtin'''</i>&nbsp; to the above
 +
in utils/wxrc/Makefile
 +
<li> add <i>'''-mmacosx-version-min=10.4'''</i>&nbsp; to the CXX = g++ line (25)
 +
<li> change the <nowiki>#</nowiki>define of ICONV_CHAR_CAST in src/common/strconv.cpp to: <br><i><b><nowiki>#define ICONV_CHAR_CAST(x) ((const char **)(x))</nowiki></b></i><br>
 +
<li> Do make followed by make install.
 +
<li> Open the audacity.xcodeproj file.  You should create a text file called Debug_Static.xcconfig in the same directory as the project file, and add the line to this text file to include the path you specified as --prefix when building wxMac.  For example 'WXPREFIX = /path/to/audacity/wx'.
 +
<li> If you get an error saying that pkg-config is required, you need to add the path of pkg-config on your system to the XCode settings by adding the line 'PATH = /sw/bin:$PATH' (if you use fink) to the .xcconfig file (in the project's XCode settings folder.  It may also be in /opt/bin if you use macports vs fink.
 +
<li> Compile Audacity 1.3.4 using Xcode. Open the latest Xcode project file and update it if required. In the list of targets do a "Get Info" on Audacity and Configure. You may need to change a few "User-Defined" settings. Most of the Wx ones need changing to which version of wxWidgets you've chosen and the path that you set above in --prefix when building it. You may have to change the CONFIG_STATIC and CONFIG_UNICODE in Configure. Most of the settings required for these variables can be gained from running wx-config --libs, --ld or --cflags.  
 +
</ol>
  
 +
'''If further problems are encountered:''' please view {{external|1=[http://audacityteam.org/forum/viewtopic.php?f=17&t=1649&st=0&sk=t&sd=a this thread]}} on the {{external|[http://audacityteam.org/forum Audacity Forum]}}.
  
'''If further problems are encountered:''' please view {{external|1=[http://audacityteam.org/forum/viewtopic.php?f=17&t=1649&st=0&sk=t&sd=a this thread]}} on the {{external|[http://audacityteam.org/forum Audacity Forum]}} or email the Audacity developer list:<br>(audacity-devel _AT_ lists_DOT_sourceforge_DOT_net) or click {{external|1=[mailto:[email protected]?subject=Building_on_Mac here]}}.
+
=== Broken script to build Universal Binary ===  
  
 +
A {{external|[https://web.audacityteam.org/files/audacity_mac_universal_binary.sh script]}} was available that built  a Universal Binary version of Audacity on OS X 10.4. The script started with a wxMac-2.6.4 tarball, downloaded a fresh copy of Audacity from CVS, compiled both targets separately, merged them into the universal binary, and finally made the disk image. 
  
'''Update (27 Jan 08):''' A {{external|[http://audacity.sourceforge.net/files/audacity_mac_universal_binary.sh script]}} is now available that builds a Universal Binary version of Audacity from CVS. Currently the build requires Mac OS X 10.4. If you were using an earlier version of the script, please update using the above link. The earlier version may accidentally link to system libraries in error. The script starts with a wxMac-2.6.4 tarball and downloads a fresh copy of Audacity from scratch from CVS, compiles both targets separately and then merges them into the universal binary, finally making the disk image.
+
As of 1 Nov 08 the script was broken, Audacity head being built using wx 2.8.10.
  
'''Update (1 Nov 08):''' The above script is broken when using audacity head from cvs. The head of audacity cvs is now built using wx 2.8.10.
 
  
 
[[Category:Mac Platform]] [[Category:For Developers]]
 
[[Category:Mac Platform]] [[Category:For Developers]]

Latest revision as of 19:34, 15 September 2018

Warning icon This article is now largely of historical interest only. See Building On Mac instead.
  • This page explains the general principles of building a universal binary of Audacity on Mac from SVN and the issues and solutions doing so up to 2012/early 2013.

If you still need help after reading Building On Mac, please ask on the Compiling Audacity section of our Forum.

Related article(s):

Prerequisites

You will need pkgconfig installed. By default this is not on your mac, but if you use fink or macports you may already have it in /sw/bin or /opt/bin. If you don't have it, you'll need to install fink. Then you can get it using fink with the command

fink install pkgconfig

Alternatively you can use macports to install it.

Get Audacity from the SVN repository.

Building Universal Binary

Generally it was easier to build a native PPC or Intel version than a Universal Binary needed for public releases of Audacity.

Instructions at June 2010

These instructions were copied from an email on audacity-devel in June 2010.

  1. svn checkout http://audacity.googlecode.com/svn/audacity-src/trunk/ audacity
  2. cd audacity/mac
  3. xcodebuild -target Audacity -configuration "Release Static" WX_PREFIX=<location of wxMac>

    Building with a shared wxMac is possible but is not really worth the extra trouble required.

    wxMac needs patching to work properly with Audacity (a few bug fixes). The patches are found in the mac directory of the Audacity sources.
  4. If Audacity fails to build due to missing configure macros you will need to add a file called "dirlist" to /usr/share/aclocal (dirlist should contain a list of extra places to check for m4 macros, one per line)
  5. Add the directory containing you pkg-config m4 macros - should be something like
    /PATH PKG-CONFIG INSTALLED TO/share/aclocal
  6. If you wish to use Xcode to build Audacity in a GUI environment, add any configuration, like WX_PREFIX, to the relevant .xcconfig file. There are four, one for each build setting.

Working scenario building Universal Binary on PPC or Intel Mac OS X 10.5

The following scenario was reported to build from SVN HEAD as a Universal Binary on both Power PC and Intel Mac on OS X 10.5.1, using Xcode 3 and either wxWidgets 2.6.4 or 2.8.11, or the OS X 10.5.1 wxWidgets shared library.

Note that if you used OS X 10.6 Snow Leopard or later there were likely to be various problems.

General Principles

1 Setup wxWidgets
1.1 -Create a wx directory in your audacity directory. For example: $HOME/audacity/wx
1.2 -If for some reason you are using wxMac 2.8.10, Patch the wxMac2.8.10 by doing the following
cd /path/to/wxMac-2.8.10

patch -p1 < /path/to/audacityrepos/mac/wxMac-2.8.10.patch

1.3 -Build wxWidgets from the command line. Make a build directory inside the wxWidgets directory and from there run (without the line breaks):
../configure --disable-shared --enable-universal_binary
--prefix=/path/to/audacity-beta/wx/ --enable-static --enable-unicode 
--disable-dependency-tracking --disable-monolithic --enable-debug

For wxWidgets 2.6.x:
  1. add --with-expat=builtin  to the above
  2. in utils/wxrc/Makefile add -mmacosx-version-min=10.4  to the CXX = g++ line (25)
  3. change the #define of ICONV_CHAR_CAST in src/common/strconv.cpp to:
    #define ICONV_CHAR_CAST(x) ((const char **)(x))

2. Do make followed by make install (by typing 'make', then 'make install'. If you have the wx-prefix outside of your home directory you may need 'sudo make install' instead, which will prompt you for a password.)
3. Open the audacity.xcodeproj file. You should create a text file called Debug_Static.xcconfig in the same directory as the project file, and add the line to this text file to include the path you specified as --prefix when building wxMac. For example 'WXPREFIX = /path/to/audacity/wx'.
3.5. If you get an error saying that pkg-config is required, you need to add the path of pkg-config on your system to the XCode settings by adding the line 'PATH = /sw/bin:$PATH' (if you use fink) to the .xcconfig file (in the project's XCode settings folder. It may also be in /opt/bin if you use macports vs fink.
4. Compile Audacity using Xcode. Open the latest Xcode project file and update it if required. In the list of targets do a "Get Info" on Audacity and Configure. You may need to change a few "User-Defined" settings. Most of the Wx ones need changing to which version of wxWidgets you've chosen and the path that you set above in --prefix when building it. You may have to change the CONFIG_STATIC and CONFIG_UNICODE in Configure. Most of the settings required for these variables can be gained from running wx-config --libs, --ld or --cflags. Also note that if using OS X 10.6 you may have to set xcode to use gcc 4.0 instead of 4.2 in your project settings.
4.1 If you get an error related to libflac, you have libflac installed to /usr/local/lib, and Audacity is linking to this instead of the libflac that the project builds. To workaround this, rename /usr/local/lib/libFLAC.dylib and libFLAC++.dylib to something else. A more proper workaround would be changing the include and linker paths to remove /usr/local/lib.

Troubleshooting tips

  • Install pkg-config and make sure it's in your path; If it's not in your path Xcode won't find it and nothing will build
  • Ensure that you have wxMac installed and that you know where it is - you can use the libraries that Apple provide but they're old and not great
  • Do not try and build Audacity from the configure script, because you won't get a fully working universal binary - use the Xcode project instead. Open the Xcode project either from the command line or via the Finder.
  • If wxMac is not installed to /usr/local you will have to set it up yourself. Either open Xcode like this:
    xcodebuild -target Audacity -configuration "Release Static" WX_PREFIX=/path/wxMac/installed/to
    or set it in xcode via the appropriate .xcconfig file or the WX_PREFIX variable in the project
  • If Audacity fails to build due to missing configure macros you will need to add a file called "dirlist" to /usr/share/aclocal . The dirlist should contain a list of extra places to check for m4 macros, one per line. Add the directory containing you pkg-config m4 macros - it should be something like:
    /PATH PKG-CONFIG INSTALLED TO/share/aclocal

Even older information

For wxWidgets 2.6.x

  1. add --with-expat=builtin  to the above in utils/wxrc/Makefile
  2. add -mmacosx-version-min=10.4  to the CXX = g++ line (25)
  3. change the #define of ICONV_CHAR_CAST in src/common/strconv.cpp to:
    #define ICONV_CHAR_CAST(x) ((const char **)(x))
  4. Do make followed by make install.
  5. Open the audacity.xcodeproj file. You should create a text file called Debug_Static.xcconfig in the same directory as the project file, and add the line to this text file to include the path you specified as --prefix when building wxMac. For example 'WXPREFIX = /path/to/audacity/wx'.
  6. If you get an error saying that pkg-config is required, you need to add the path of pkg-config on your system to the XCode settings by adding the line 'PATH = /sw/bin:$PATH' (if you use fink) to the .xcconfig file (in the project's XCode settings folder. It may also be in /opt/bin if you use macports vs fink.
  7. Compile Audacity 1.3.4 using Xcode. Open the latest Xcode project file and update it if required. In the list of targets do a "Get Info" on Audacity and Configure. You may need to change a few "User-Defined" settings. Most of the Wx ones need changing to which version of wxWidgets you've chosen and the path that you set above in --prefix when building it. You may have to change the CONFIG_STATIC and CONFIG_UNICODE in Configure. Most of the settings required for these variables can be gained from running wx-config --libs, --ld or --cflags.

If further problems are encountered: please view this thread  on the Audacity Forum .

Broken script to build Universal Binary

A script  was available that built a Universal Binary version of Audacity on OS X 10.4. The script started with a wxMac-2.6.4 tarball, downloaded a fresh copy of Audacity from CVS, compiled both targets separately, merged them into the universal binary, and finally made the disk image.

As of 1 Nov 08 the script was broken, Audacity head being built using wx 2.8.10.