wiki:MacBuild

Version 76 (modified by Christian Beer, 11 years ago) (diff)

update to boinc-v2.git

Building BOINC Client and Manager on Macintosh OS X

Last updated 12/12/12

This document applies to BOINC version 7.0.42 and later. It has instructions for building the BOINC Client and Manager for Macintosh OS X. For information on building science project applications to run under BOINC on Macintosh OSX, see BuildMacApp.

Note: the information in this document changes from time to time for different versions of BOINC. For any version of BOINC source files, the corresponding version of this document can be found in the source tree at:

boinc/mac_build/HowToBuildBOINC_XCode.rtf

Contents of this document:

  1. Building BOINC Client and Manager on Macintosh OS X
    1. Important requirements for building BOINC software for the Mac
    2. Cross-Platform Development
    3. Building BOINC Manager with embedded BOINC Client
    4. Building BOINC Manager Installer
    5. Code Signing the BOINC Manager Installer and Uninstaller
    6. Debugging and BOINC security
    7. Debugging into wxWidgets
    8. Installing and setting up Xcode

Important requirements for building BOINC software for the Mac

Building BOINC for Macintosh OS X is complicated by the fact that Mac OS X is actually 2 different platforms:

  • i686-apple-darwin: 32-bit Intel processors running OS 10.4.0 and above
  • x86_64-apple-darwin: 64-bit Intel processors running OS 10.5.0 and above

As of version 6.13.0, BOINC does not support Macintosh PowerPC processors.

Although BOINC supports 64-bit Intel project applications on Mac OS 10.5.0 and above, the only part of the BOINC client package built as a 64-bit executable is the screensaver coordinator for OS 10.6.x and later. The BOINC libraries also include a 64-bit build so that they can be linked with 64-bit project applications.

You need to take certain steps to ensure that you use only APIs that are available in all the OS versions BOINC supports for each architecture. The best way to accomplish this is to use a single development system running OS 10.7.x or OS 10.8.x and cross-compile for the various platforms. The remainder of this document describes that process.

The above requirements apply not only to BOINC itself, but also to the WxWidgets, c-ares, cURL, openSSL, freetype, ftgl and SQLite3 libraries, as well as all project applications.

Be sure to follow the directions in this document to ensure that these requirements are met.

Starting with version 6.10.58, the BOINC Client supports only Mac OS X 10.4.0 and later. This allows it to be built with XCode 3.2 and later, which do not support the Mac OS 10.3.9 SDK.

Cross-Platform Development

Apple provides the tools necessary to cross-compile for both BOINC Mac platforms on any Mac running OS 10.7.x or OS 10.8.x.

You get these tools, including the GCC compilers and system library header files, by installing the XCode Tools package.

Building BOINC now requires Xcode Tools version 3.2 or later but Xcode 4.3 or later is recommended.

You can download Xcode 4.3 or Xcode 4.4 from Apple's App Store (it is large: about 2 GB). If you are a member of Apple's Mac Developer Program, you can also download it from Apple's web site: http://developer.apple.com. You can also register for free access to Apple developer tools at: https://developer.apple.com/programs/register/.

Source files are now archived within the BOINC repository (mac_build).

Building BOINC Manager with embedded BOINC Client

BOINC depends on six third-party libraries: wxMac-2.8.10, c-ares-1.9.1, curl-7.26.0, openssl-1.0.1c, freetype-2.4.10, ftgl-2.1.3~rc5 and sqlite3.7.14.1. You can obtain the source files from the following URLs:

wxMac-2.8.10 (needed only if you are building the BOINC Manager):

http://www.wxwidgets.org

http://prdownloads.sourceforge.net/wxwindows/wxMac-2.8.10.tar.gz

http://downloads.sourceforge.net/wxwindows/wxMac-2.8.10.tar.bz2

sqlite3.7.14.1 (needed only if you are building the BOINC Manager):

http://www.sqlite.org/

http://www.sqlite.org/sqlite-autoconf-3071401.tar.gz

curl-7.26.0:

http://curl.haxx.se

http://curl.haxx.se/download/curl-7.26.0.tar.gz

c-ares-1.9.1 (used by curl):

http://daniel.haxx.se/projects/c-ares/

http://c-ares.haxx.se/download/c-ares-1.9.1.tar.gz

openssl-1.0.1c:

http://www.openssl.org/

http://www.openssl.org/source/openssl-1.0.1c.tar.gz

freetype-2.4.10 (needed only if you are building the BOINC default screensaver or a project screensaver):

http://www.freetype.org/

http://sourceforge.net/projects/freetype/files/freetype2/2.4.10/freetype-2.4.10.tar.bz2

ftgl-2.1.3~rc5 (needed only if you are building the BOINC default screensaver or a project screensaver):

http://sourceforge.net/projects/ftgl

http://sourceforge.net/projects/ftgl/files/FTGL%20Source/2.1.3%7Erc5/ftgl-2.1.3-rc5.tar.gz

(Don't forget to expand the tar files by double-clicking on them.)

XCode will automatically check compatibility back to OS 10.4 if the following are defined during compilation:

MAC_OS_X_VERSION_MAX_ALLOWED=1040
MAC_OS_X_VERSION_MIN_REQUIRED=1040

These are not done automatically by either the Xcode projects which come with wxMac-2.8.10, nor the AutoMake scripts supplied with wxMac-2.8.10, c-ares-1.9.1, curl-7.26.0, openssl-1.0.1c, freetype-2.4.10, ftgl-2.1.3~rc5 and sqlite3.7.14.1. So be sure to use our special scripts to build these packages.

  1. Create a parent directory within which to work. In this description , we will call it BOINC_dev, but you can name it anything you wish.
  1. Put the following 3 directories inside the BOINC_dev folder (omit any you don't need):
    c-ares-1.9.1
    curl-7.26.0
    openssl-1.0.1c
    wxMac-2.8.10
    freetype-2.4.10
    ftgl-2.1.3~rc5
    sqlite3.7.14.1
    
    Important: do not change the names of any of these 6 directories.

Note: Building wxMac-2.8.10 requires the MacOSX10.6.sdk, which is not included in Xcode 4.4 and later. If you are building wxMac-2.8.10 with Xcode 4.4, see the section Installing and setting up Xcode for further information.

  1. Get the BOINC source tree from the repository, and put it in the same BOINC_dev folder. To do this, type the following in Terminal:
    cd {path}/BOINC_dev/
    git clone git://boinc.berkeley.edu/boinc-v2.git boinc
    
    (You may change the name of the boinc directory to anything you wish.) See more information on getting the BOINC source code.
  1. Run the script to build the c-ares, curl, openssl, wxMac, freetype, ftgl and sqlite3 libraries as follows:
    cd {path}/BOINC_dev/boinc/mac_build/
    source setupForBoinc.sh -clean
    
    If you don't wish to force a full rebuild of everything, omit the -clean argument.

Note 1: Be sure to run the script using the source command. Do not double-click on the scripts or use the sh command to run them.

Note 2: this script tries to build all six third-party libraries: wxMac-2.8.10, c-ares-1.9.1, curl-7.26.0, openssl-1.0.1c, freetype-2.4.10, ftgl-2.1.3~rc5 and sqlite3.7.14.1. when the script finishes, it will display a warning about any libraries was unable to build (for example, if you have not downloaded them.)

  1. Build BOINC as follows:

BOINC itself is built using the boinc.xcodeproj file. You can either build directly in XCode (more information below) or run the BuildMacBOINC.sh script:

cd {path}/BOINC_dev/boinc/mac_build/
source BuildMacBOINC.sh

The complete syntax for this script is

source BuildMacBOINC.sh [-dev] [-noclean] [-all] [-lib] [-client] [-help]

The options for BuildMacBOINC.sh are:

-dev
build the development (debug) version (native architecture only). default is deployment (release) version (universal binary: i386 and x86_64).
-noclean
don't do a 'clean' of each target before building. default is to clean all first.

The following arguments determine which targets to build

-all
build all targets (i.e. target 'Build_All' -- this is the default)
-lib
build the five libraries: libboinc_api.a, libboinc_graphics_api.a, libboinc.a, libboinc_opencl.a, jpeglib.a
-client
build two targets: BOINC client and command-line utility boinccmd (also builds libboinc.a, since boinc_cmd requires it.)

Both -lib and -client may be specified to build seven targets (no BOINC Manager or screensaver.)

Note: You may find two XCode projects in the BOINC_dev/boinc/mac_build/ directory:

  • wxMac-BOINC.xcodeproj was needed for building older versions of the wxMac library in conjunction with the older versions of the setupForBoinc.sh or buildWxMac.sh scripts. It is not used for BOINC 5.9.2 or later.
  • boinc.xcodeproj builds BOINC. It can be used either with the BuildMacBOINC.sh script or as a stand-alone project. The Development build configuration builds only the native architecture and is used for debugging. The Deployment build configuration builds a universal binary and is suitable for release builds. If there are any other build configurations, they should not be used as they are obsolete.

Note: To perform a release build under Xcode 4.3 when not using the BuildMacBOINC.sh script, select "Build for archiving" from Xcode's Product menu. Do not select "Archive."

The standard release of BOINC version 6.13.0 and later builds only for Macintosh computers with Intel processors. Most of the executables are built only for the i386 architecture. The BOINC libraries and the screensaver are built as universal binaries containing builds for two architectures: i386 and x86_64.

Building BOINC Manager Installer

In order to execute BOINC Manager, you have to install it using BOINC Manager Installer. Otherwise, you will encounter an error prompting for proper installation.

To build the Installer for the BOINC Manager, you must be logged in as an administrator. If you are building BOINC version number x.y.z, type the following in Terminal, then enter your administrator password when prompted by the script:

cd {path}/BOINC_dev/boinc/
source {path}/BOINC_dev/boinc/mac_installer/release_boinc.sh x y z

Substitute the 3 parts of the BOINC version number for x y and z in the above. For example, to build the installer for BOINC version 7.0.32, the command would be

source {path}/BOINC_dev/boinc/mac_installer/release_boinc.sh 7 0 32

This will create a directory 'BOINC_Installer/New_Release_7_0_32' in the BOINC_dev directory, and the installer will be located in {path}/BOINC_dev/BOINC_Installer/New_Release_7_0_32/boinc_7.0.32_macOSX_i686.

Code Signing the BOINC Manager Installer and Uninstaller

Mac OS 10.8 introduces a security feature called Gatekeeper, whose default settings won't allow a user to run applications or installers downloaded from the Internet unless they are signed by a registered Apple Developer. The release_boinc.sh script looks for a file ~/BOINCCodeSignIdentity.txt containing the name of a valid code signing identity stored in the user's Keychain. If this is found, the script will automatically sign the BOINC installer and BOINC uninstaller using that identity. For example, if your user name is John Smith, the first line of ~/BOINCCodeSignIdentity.txt would be something like the following:

Developer ID Application: John Smith

If there is no ~/BOINCCodeSignIdentity.txt file, then the script will not sign the installer or uninstaller. For more information on code signing identities see the documentation for the `codesign` utility and Apple's Code Signing Guide.

Debugging and BOINC security

Version 5.5.4 of BOINC Manager for the Macintosh introduced new, stricter security measures. For details, please see the file boinc/mac_installer/Readme.rtf and web pages Sandbox Design and Sandbox User.

The GDB debugger can't attach to applications which are running as a different user or group so it ignores the S_ISUID and S_ISGID permission bits when launching an application. To work around this, the BOINC Development build does not use the special boinc_master or boinc_project users or groups, and so can be run under the debugger from XCode.

The Development build only of the BOINC Manager allows you to change the ownership and permission settings of the BOINC Data and executables by entering an administrator user name and password. This also streamlines the development cycle by avoiding the need to run the installer for every change. (To generate the development build under Xcode 4.3, choose "Build" from the product menu, or enter command-B on the keyboard.)

To restore the standard ownerships and permissions, run the installer.

For information on interpreting crash dumps and backtraces, see Mac Backtrace.

Debugging into wxWidgets

The BOINC XCode project normally links the BOINC Manager with the non-debugging (Deployment) build of wxWidgets, even for the Development build configuration of the Manager. However, there may be times when you wish to link the Development build of the Manager to the Development build of wxWidgets for debugging, as when you want to step into internal wxWidgets code or put breakpoints in wxWidgets.

You can find instructions for doing this in the comments in the file boinc/clientgui/mac/MacGUI.pch.

Installing and setting up Xcode

Versions of Xcode prior to Xcode 4.3 have an installer package. After downloading Xcode, mount the disk image file by double-clicking on it, then double-click the installer package.

Starting with Xcode 4.3, the disk image contains a copy of Xcode itself. After mounting the disk image, drag the Xcode icon to the folder where you wish it to reside. In most cases, this will be the /Applications/ folder. Unmount the disk image by dragging it to the trash. Finally, double-click on the installed Xcode icon to run Xcode. Xcode will display a dialog allowing you to finish the installation; you must do this before running BOINC's build scripts. (Some versions of Xcode may not display this dialog until you open a file with Xcode.)

Building wxMac-2.8.10 requires the MacOSX10.6.sdk, which is not included in Xcode 4.4 and later. If you are building wxMac-2.8.10 with Xcode 4.4, you must install the OS 10.6 SDK as follows:

  1. Download a version of Xcode for OS 10.7 Lion (such as Xcode 4.3.3.)
  1. Mount the disk image file by double-clicking on it. Do not drag-install this older version of Xcode.
  1. On the disk image, control-click on the Xcode icon and select Show Package Contents.
  1. On the older Xcode disk image, browse to the directory:
    /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
    
    You should see a folder named MacOSX10.6.sdk.
  1. Control-click on your newer Xcode icon (which you previously installed on your hard drive) and select Show Package Contents.
  1. In your newer Xcode Browse to the directory:
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/`
    
    (or the equivalent if you installed it somewhere other than your /Applications/ folder.)
  1. Copy the MacOSX10.6.sdk folder from the SDKs folder on the older disk image to the SDKs folder in the newer Xcode.
  1. Unmount the disk image by dragging it to the trash.