Compiling For Mac

I finally decided to contribute to Audacity. Unfortunately, the build process for Mac is totally broken.

  • I have a white Macbook running 10.5.6 and I’ve been successfully developping all kind of Mac software, so I know that my Xcode installation works great.

  • I have successfully installed and compiled wxMac-2.8.9

  • I have downloaded the latest version via CVS

  • Whenever I ty to compile from the command line or from Xcode, I get an error saying that pkg-config could not be found.


checking for pkg-config… no
configure: error: pkg-config is required to compile audacity!

  • On the Mac, pkg-config 0.21 is automatically installed in all systems (at least it was on mine).
  • Do you actually have people testing the Mac compiling process from Xcode?
  • Is it looking for pkg-config in a non-standard location on the Mac?
  • How could this be fixed?

Audacity is such a great project, but if compiling was more straightforward, it wud get more contributors.

  • Nick -


    Thanks

I’ve sent a message via the audacity mailing list to answer this but it’s here as well for others.

I run a server that builds Audacity from scratch every night on OSX to check that the build process works. I probably know before anyone else whether or not the OSX build is broken.

Currently two things need to be done to get Audacity to build.

First, 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.

Second, 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, you wont 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

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

Should be something like :-

/PATH PKG-CONFIG INSTALLED TO/share/aclocal

Any other problems then just send me an email.

Regards,

Paul.

As it turned out, a recent install of Fink was the cause of my problem. Removing Fink and installing MacPort resolved the issue. I’m not sure what’s wrong with Kink, but I prefer to use what other Audacity users are using.

Paul, I think you should also just add this to the Wiki OS-X compiling page, where most people will go for help. You should also mention the recent patch to apply to wxMac so that people can just compile wxMac once.

Thanks for your great work,

  • Nick -

I was running into a similar problem using Fink tonight.

If you use fink, you’ve probably installed pkg-config into /sw/bin/. I long ago I added that directory to my PATH in my .profile file and could successfully configure audacity from the command line. While I could configure audacity from the command line, XCode would error out, complaining that it couldn’t find pkg-config.

XCode doesn’t load your PATH customizations from ~/.profile, nor does it look in /etc/paths. In order to fix this problem, you’ll need to update your PATH so that XCode can see the changes.

Here’s an article describing how to make the change:
http://developer.apple.com/qa/qa2001/qa1067.html

I’m really new to the Mac development environment. I’ve been programming since the early 1980s. I used to use a several flavors of UNIX before 1994, but have been working on Windows ever since - so I really do need some detailed help to get started. I have had a Mac at home since the early 1990s, and just bought an IMac a month ago. So, now I have Mac OS 10.5.7, and XCode 3.0, wxWidgets/wxMac 1.8.10, Audacity 3.4.x (just downloaded), and pkg-config 0.23.

My question: how do I properly install pkg-config on my Mac? Then, how do I make sure that XCode can find it in the “$PATH” environment variable that XCode is using? When I try to build audacity, all I get is the error
checking for pkg-config… no
configure: error: pkg-config is required to compile audacity!

Hope someone can help me!
Thanks,
Dusty

OK,

I’ll need a little extra information. How did you install pkg-config?

Regards,

Paul.

After downloading the file and placing it in /Users/John/Development/pkg-config, I opened up the Terminal window, and ran the following steps
cd /Users/John/Development/pkg-config
tar xvf pkg-config-0.23.tar
cd pkg-config-0.23
./configure
make
sudo make install

Any suggestions?

Dusty

OK,

From memory pkg-config install to /usr/local by default.

So, you need to add /usr/local/bin to your path.

Assuming that your shell is bash, you can either add it on the commend line

export PATH=$PATH:/usr/local/bin
and then run xcode from the shell or a more permanent fix is to add it to one of your start up scripts.

$HOME/.bashrc is as good a place as any to add the above line.

You may need to log out and back in again for this to take effect in Xcode.

Regards,

Paul.

Hello,

I am trying to compile Audacity for Mac OS X 10.5.8

I’ve downloaded and installed:
pkg-config-0.23
wxMac-2.8.10

When I try to compile Audacity from the command line with the following line in the mac/compile.txt file:

./configure --enable-static

I receive the output:

...
checking for a BSD-compatible install... /usr/bin/install -c
checking for pkg-config... yes
checking for a sed that does not truncate output... /usr/bin/sed
...

And notice that the shell DOES find pkg-config.
However, it returns the following:

checking for wx-config... /usr/bin/wx-config

  Warning: No config found to match: /usr/bin/wx-config --static=yes --unicode=yes --version
           in /usr/lib/wx/config
  If you require this configuration, please install the desired
  library build.  If this is part of an automated configuration
  test and no other errors occur, you may safely ignore it.
  You may use wx-config --list to see all configs available in
  the default prefix.

configure: Checking that the chosen version of wxWidgets is 2.8.x
configure: error: Unable to locate a suitable configuration of wxWidgets v2.8.x or higher.
The currently available configurations are listed below.  If necessary, either
install the package for your distribution or download the latest version of
wxWidgets
from http://wxwidgets.org.

    Default config is mac-unicode-debug-2.8

  Default config will be used for output

continuing with the terminal, I then try the command:

make

which returns the error:

make: *** No targets specified and no makefile found.  Stop.

So, I then try using the mac/Audacity.xcodeproj
and when I click “Build” it returns the error:

configure: error: pkg-config is required to compile audacity!

I confess I am a newbie, so I created a file called .bashrc in my home directory and added the one line:

export PATH=$PATH:/usr/local/bin

That did not seem to work either.

What am I doing wrong? Or, how can I compile Audacity?

Thank you for your help!
Maximum respect,
GuitarGuy91403

OK, the error you got is cryptic but correct.

When you say you’ve installed wxMac 2.8.10, exactly which version? wxMac can be built as release or debug, ansi or unicode and dynamically or statically; giving a total of 8 different combinations. What you’ve asked audacity to build with is a static, unicode and release version of wxMac which can’t be found.

For ease, I find it easiest to build all four unicode versions of wxMac.

This should do that for you, put it in a script and run it, remembering to set PREFIX up first

#!/bin/sh
#export MACOSX_DEPLOYMENT_TARGET=10.4
#export NEXT_ROOT=“/Developer/SDKs/MacOSX10.4u.sdk”
#export C_INCLUDE_PATH=“/Developer/SDKs/MacOSX10.4u.sdk/usr/include”
#export LIBRARY_PATH=“/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/darwin/3.3”
#export CPPFLAGS=“-DMAC_OS_X_VERSION_MAX_ALLOWED=1040 -mmacosx-version-min=10.4”
#export CFLAGS=“-DMAC_OS_X_VERSION_MAX_ALLOWED=1040 -isysroot $NEXT_ROOT
#-mmacosx-version-min=10.4”
#export CXXFLAGS=“-DMAC_OS_X_VERSION_MAX_ALLOWED=1040 -isysroot $NEXT_ROOT
#-mmacosx-version-min=10.4”
#export LDFLAGS=“-DMAC_OS_X_VERSION_MAX_ALLOWED=1040
#-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -flat_namespace”
#export MAKEFLAGS=“-j 7”

#SET UP THE FOLLOWING LINE
PREFIX=/Wherever/you/want/it/to/be/installed/to
CONF_LINE=“…/configure --prefix=${PREFIX} --with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk
–with-macosx-version-min=10.4 --disable-compat26 --with-expat=builtin --with-zlib=builtin --with-regex=builtin --enable-universal_binary=yes --enable-unicode=yes”

if [ -n “$1” ]
then
#Shared Release
rm -rf bld-ShRel
mkdir bld-ShRel
cd bld-ShRel
${CONF_LINE} --enable-static=no --enable-shared=yes --enable-debug=no
make clean
make
sudo make install
cd …

#Static Release
rm -rf bld-StRel
mkdir bld-StRel
cd bld-StRel
${CONF_LINE} --enable-static=yes --enable-shared=no --enable-debug=no
make clean
make
sudo make install
cd …

#Static Debug
rm -rf bld-StDeb
mkdir bld-StDeb
cd bld-StDeb
${CONF_LINE} --enable-static=yes --enable-shared=no --enable-debug=yes
make clean
make
sudo make install
cd …
fi

#Shared Debug
rm -rf bld-ShDeb
mkdir bld-ShDeb
cd bld-ShDeb
${CONF_LINE} --enable-static=no --enable-shared=yes --enable-debug=yes
make clean
make
sudo make install

cd …
#rm -rf bld

Other things to note, Audacity requires a slightly patched version of wxMac. the patch file is held in the Audacity source tree and is called wxMac-2.8.10.patch
This patch needs to be applied to the wxMac source tree before you can get a version that will work properly.

I hope that this helps,

Paul.

Paul,

I have a couple questions about the script in your most recent post. For the PREFIX, is /usr/local a good value? Also, are the other options to configure (other than --prefix and the --enable-* ones) necessary?

Thanks!

Hi,

The other options to configure while not strictly necessary, are a good idea. We’re telling configure to use wxMac’s versions of certain libraries, and to build in OSX 10.4 compatibility mode. This is known to work.

You can use /usr/local as your install path, the only thing to note is that you may need to tell audacity where wxMac is when you try to build it.

eg.

xcodebuild -target Audacity -configuration “Release Static” WX_PREFIX=/usr/local

or

xcodebuild -target Audacity -configuration “Debug Static” WX_PREFIX=/usr/local

If you want to build with a shared wxMac library you will probably need to add /usr/local/lib to your LD_LIBRARY_PATH variable, but if I were you I wouldn’t build shared anyway.

If you use Xcode to do your building from the IDE you will need to set up WX_PREFIX in the configuration files as described in an earlier post.

I hope that this helps,

Paul.

Hi Paul,

I tried running the script, but it returns the error:

/Users/guitarguy91403/Desktop/wxMac-2.8.10/docs/ShellScript.txt: line 57: ../configure: No such file or directory
make: *** No rule to make target `clean'.  Stop.
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target `install'.  Stop.

Does this mean my ShellScript is in the wrong location?

Thanks for your help…

Maximum respect,
GuitarGuy91403

Hi,

You need to run the script from inside the wxMac source directory, that should solve your problems. It looks like you’re trying to run it from inside a lower level directory, namely docs.

Paul.

Thanks Paul,

I moved the script and figured out that I was trying to run the script improperly.
To get it to run:

First, I had to:

chmod +x ~/Desktop/wxMac-2.8.10/ShellScript

Then, I ran the script using:

~/Desktop/wxMac-2.8.10/ShellScript

Then, it churned away for a while, and then returned this message:

ld: in /Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib/libJPEG.dylib, file is not of required architecture
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//cc18aKng.out (No such file or directory)
make: *** [/Users/guitarguy91403/Desktop/wxMac-2.8.10/bld-ShDeb/lib/libwx_base_carbonud-2.8.0.6.0.dylib] Error 1

/Developer/SDKs/MacOSX10.4u.sdk/usr/local/lib is a symbolic link to /usr/local/lib, ie user installed libraries, not system ones

So, somewhere along the line, you’ve installed libJPEG yourself but only a single architecture version and this is getting found before the proper system one.

libJPEG should be found in /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework

You probably have /usr/local/lib in your LD_LIBRARY_PATH and this is causing you trouble. You can’t remove it though because this is where you want to install wxMac.

Simple solution, replace libJPEG in /usr/local/lib with a “fat” multi-architecture version, or find out if it’s needed at all and remove it if not.

This often points to your system having fink or one of the other “ports” systems installed and this can cause trouble trying to build Audacity as incorrect/unexpected versions of libraries are found.

I hope that this helps,

Paul.

Paul-
thanks again -
removing libjpeg worked - sort of

So, I used the “Release Static” configuration, and modified the WX_CFLAGS so that it looked for “mac-ansi-release-static-2.8” which is on my computer.

Then when I build, it actually accomplishes quite a bit until it hits the script

ImportQT.cpp

It runs into an error on line 236:

 UInt32 quality = kQTAudioRenderQuality_Max;
 
error: 'kQTAudioRenderQuality_Max' was not declared in this scope

any ideas?
Max respect
guitarguy91403

I think ansi builds are not necessarily good.

All I can suggest is build a unicode wxMac and then build the corresponding Audacity. The current source tree does work according to my nightly build machine.

xcodebuild -target Audacity -configuration “Debug Static” WX_PREFIX=whatever

Hope this helps,

Paul.

Hi Paul,

I downloaded a fresh version of audacity-fullsrc-1.3.9.tar.bz2.
I built all four unicode versions of wxMac.
It also finds pkg-config properly.

However, I am still getting an error in line 236 of ImportQT.cpp:

UInt32 quality = kQTAudioRenderQuality_Max;



error: ‘kQTAudioRenderQuality_Max’ was not declared in this scope

What do you think? Thanks for your help…
Max respect
GuitarGuy91403

OK, a quick question that might help, what OS and version of Xcode are you using?

Regards,

Paul.