200 | | == Building project applications == |
201 | | |
202 | | === Upgrading applications for Macs with Intel processors === |
203 | | |
204 | | Apple converted all its lines of computers to Intel processors during 2006. The early Intel Macs used the Core Duo processor, which is a 32-bit CPU. Later Intel processors, including the Core 2 Duo, can run both 32-bit and 64-bit applications. However, BOINC will run in 64-bit mode only under OS 10.5 and later. |
205 | | |
206 | | All current releases of BOINC include "universal binary" builds for the Macintosh of BOINC Manager, command-line BOINC Client and the boinc_cmd command-line tool. (Universal binaries contain both PowerPC and Intel executables in one file; the Macintosh OS automatically selects the appropriate one for that computer.) Beginning with version 6.1, the BOINC Client and libraries also include the 64-bit Intel architecture as part of the universal binaries. |
207 | | |
208 | | The advantage of 'universal binaries' is that you only need to have one copy of the application, and it will run on either PowerPC or Intel Macs, so users don't need to choose between two options. Since BOINC participants manually download BOINC from the web site, we will be providing BOINC in 'universal binary' form. |
209 | | |
210 | | However, participants do not manually download project applications; this is done automatically by BOINC. So there would be no advantage to combining the 32-bit Intel, 64-bit Intel and PowerPC versions in a single 'universal binary' file, but doing so would triple the size of the download. |
211 | | |
212 | | So BOINC treats Intel Macs as 2 new, separate platforms: `i686-apple-darwin` and `x86_64-apple-darwin`, in addition to the PowerPC Mac platform (`powerpc-apple-darwin`). |
213 | | |
214 | | Starting with BOINC 5.9.7, the Intel BOINC Client accepts powerpc-apple-darwin applications if no i686-apple-darwin is available. The OS will run it in compatibility mode, emulating a PowerPC. (Apple calls this compatibility mode Rosetta, which of course has nothing to do with the Rosetta BOINC project.) |
215 | | |
216 | | The x86_64 BOINC Client requests `x86_64-apple-darwin` applications from BOINC servers as its first choice, `i686-apple-darwin` as a second choice, and finally `powerpc-apple-darwin` if no Intel applications are available. |
217 | | |
218 | | However, older Intel Mac clients will not get any work unless the server offers i686-apple-darwin applications. As a '''temporary''' measure, projects can set their servers to deliver a copy of their current PowerPC application (renamed for the new platform) under the i686-apple-darwin platform for older BOINC Clients. |
219 | | |
220 | | If you do this, be sure to give your native Intel application a higher version number when you do release it, so that clients will download it. |
221 | | |
222 | | However, running a PowerPC application in compatibility mode has two significant drawbacks: |
223 | | |
224 | | * Screensaver graphics do not work. |
225 | | * Since it is running under emulation, your application will run at reduced efficiency. But the benchmarks are based on running native Intel applications. This may cause scheduler problems, such as missed deadlines and inadequate credit for participants. |
226 | | |
227 | | So it is important to make a native Intel application available as soon as possible. It is very easy to add a new [BoincPlatforms platform] to your server with the [XaddTool xadd utility]. |
228 | | |
229 | | BOINC 6.1 supports all PowerPC Macs running OS 10.3.9 or later, and all Intel Macs, but older versions of BOINC supported OS 10.3.0 or later for PowerPC Macs. (The Intel Macs themselves require OS 10.4.4 or later.) |
230 | | |
231 | | The easiest way to build your application for these two platforms is to build each one on its native platform. In other words, do your `powerpc-apple-darwin` build on a PowerPC Mac running OS 10.3.9, and your `i686-apple-darwin` build on an Intel Mac. |
232 | | |
233 | | But Apple provides the tools to allow you to cross-compile your application on any Mac (PowerPC or Intel) running OS 10.4 or later. Here is how: |
234 | | |
235 | | All BOINC project applications for Power PC Macs must be built using GCC 3.3 and MacOS10.3.9 SDK to assure backward compatibility with OS 10.3. If building a PowerPC application on an Intel Mac, you must also specify `-arch ppc` in the compiler and linker flags. |
236 | | |
237 | | All 32-bit BOINC software for Intel Macs must be built using GCC 4.0 and MacOS10.4.u SDK to allow cross-compiling. If building an Intel application on a PowerPC Mac, you must also specify `-arch i386` in the compiler and linker flags. |
238 | | |
239 | | All 64-bit BOINC software for Intel Macs must be built using GCC 4.0 and MacOS10.5 SDK. To build for the x86_64 architecture, use a Mac running either OS 10.4 or OS 10.5 and specify the `-arch x86_64` option to the compiler and linker. |
240 | | |
241 | | If you prefer, you can cross-compile on one Mac running OS 10.4.x or OS 10.5.x. You can find examples of how to do this for two different kinds of configure / make scripts in the HEAD branch of the BOINC SVN tree at [source:trunk/boinc/mac_build/buildcurl.sh boinc/mac_build/buildcurl.sh] and [source:trunk/boinc/mac_build/buildjpeg.sh boinc/mac_build/buildjpeg.sh]. |
242 | | |
243 | | The lipo utility is used at the end of each of these scripts to combine the two binaries into a single "Universal Binary" file. You won't need to do that with you project applications, since you will be distributing them separately under the two platforms. But if you prefer, you can create a Universal Binary and distribute the same file for both i686-apple-darwin and powerpc-apple-darwin platforms (and also the x86_64-apple-darwin platform if you wish). |
244 | | |
245 | | Note that the BOINC libraries (and any third-party libraries) which you link with your applications must be built with the same configuration as the application itself. Follow the instructions earlier in this document to build the needed libraries. |
246 | | |
247 | | Additional information on building Unix applications universal can be found here: |
248 | | http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html |
249 | | |
250 | | and here: |
251 | | http://developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/universal_binary_compiling/chapter_2_section_7.html |
252 | | |
253 | | For information on making your code work with GCC 4: |
254 | | http://developer.apple.com/releasenotes/DeveloperTools/GCC40PortingReleaseNotes/index.html |
255 | | |
256 | | === Upgrading applications for version 6 graphics === |
257 | | |
258 | | One of the major changes in BOINC for version 6 is that applications are now expected to generate graphics in a separate executable. The graphics application typically communicates with the worker application using shared memory. |
259 | | |
260 | | For additional information, please see [milestone:6.0 the 6.0 roadmap] and the [GraphicsApi Graphics API] page. |
261 | | |
262 | | === Adding a Finder icon to your graphics application === |
263 | | |
264 | | There is an optional API `setMacIcon()` in the `libboinc_api.a` library. This allows science graphics applications to display an application icon in the Dock and in the Finder. (The icon does not appear in the Dock until the application displays graphics.) To implement this, do the following: |
265 | | |
266 | | * Use '/Developer/Applications/utilities/Icon Composer.app' to create a xxx.icns file. (Use any name you wish instead of xxx.) |
267 | | * Convert the xxx.icns file to an app_icon.h file as follows: in Terminal, run: |
268 | | {{{ |
269 | | {path}/MakeAppIcon_h {source_file_path}/xxx.icns {dest_file_path}/app_icon.h |
270 | | }}} |
271 | | (The !MakeAppIcon_h command-line utility is built by the Mac boinc XCode project in the 'boinc/mac_build/build/' directory.) Add the app_icon.h file to your graphics application's project. |
272 | | * In the graphics application's main(), add |
273 | | {{{ |
274 | | #include "app_icon.h" |
275 | | }}} |
276 | | and call: |
277 | | {{{ |
278 | | setMacIcon(argv[0], MacAppIconData, sizeof(MacAppIconData)); |
279 | | }}} |
280 | | * The graphics application must link with Carbon.framework to use setMacIcon(). |