]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/osx/install.txt
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / docs / osx / install.txt
... / ...
CommitLineData
1wxWidgets for Mac OS X installation
2-----------------------------------
3
4wxWidgets can be compiled using Apple's Carbon or Cocoa libraries.
5Carbon is the older library, and Cocoa is the more modern library.
6
7In wxWidgets 2.9.x, Cocoa is the recommended library. While Carbon is still
8supported by Apple, little new work is being done in Carbon.
9
10Most Mac OS X developers should start by downloading and installing Xcode
11from http://developer.apple.com. It is a free IDE from Apple that provides
12all of the tools you need for working with wxWidgets.
13
14After Xcode is installed, download either wxWidgets-{version}.tar.gz or
15wxMac-{version}.tar.gz and then double-click on it to unpack it to create
16a wxWidgets directory.
17
18Next use Terminal (under Applications, Utilities, Terminal) to access a command
19prompt. Use cd to change directories to your wxWidgets directory and execute
20one of the following sets of commands from the wxWidgets directory.
21
22For Carbon, you'll need to have Xcode 3.x installed (you can also have Xcode 4.x
23installed, but the Carbon build needs 3.x, and the /Developer directory which is
24installed when you install Xcode 3.x.
25
26---------
27
28# Build the library for Cocoa (wxWidgets 2.9.0 and later)
29mkdir build-cocoa-debug
30cd build-cocoa-debug
31../configure --with-osx_cocoa --enable-debug
32make
33# Build the samples and demos
34cd samples; make;cd ..
35cd demos; make;cd ..
36
37---------
38
39# Build the library for Carbon
40mkdir build-carbon-debug
41cd build-carbon-debug
42../configure --enable-debug --disable-shared --enable-macosx_arch=i386 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk CC=/Developer/usr/bin/gcc-4.2 CXX=/Developer/usr/bin/g++-4.2 LD=/Developer/usr/bin/ld
43make
44# Build the samples and demos
45cd samples;make;cd ..
46cd demos; make;cd ..
47
48---------
49
50After the compilation completes, use Finder to run the samples and demos
51 Go to build-carbon-debug/samples to experiment with the Carbon samples.
52 Go to build-carbon-debug/demos to experiment with the Carbon demos.
53 Go to build-cocoa-debug/samples to experiment with the Cocoa samples.
54 Go to biuld-cocoa-debug/demos to experiment with the Cocoa demos.
55Double-click on the executables which have an icon showing three small squares.
56The source code for the samples is in wxWidgets/samples
57The source code for the demos is in wxWidgets/demos
58
59---------
60
61More information about building on Mac OS X is available in the wxWiki.
62Here are two useful links
63 http://wiki.wxwidgets.org/Guides_%26_Tutorials
64 http://wiki.wxwidgets.org/Development:_wxMac
65
66---------
67
68More advanced topics are covered below.
69
70---------
71
72If you want to install the library into the system directories you'll need
73to do this as root. The accepted way of running commands as root is to
74use the built-in sudo mechanism. First of all, you must be using an
75account marked as a "Computer Administrator". Then
76
776) sudo make install
787) type <YOUR OWN PASSWORD>
79
80Note that while using this method is okay for development, it is not
81recommended that you require endusers to install wxWidgets into their
82system directories in order to use your program. One way to avoid this
83is to configure wxWidgets with --disable-shared. Another way to avoid
84it is to make a framework for wxWidgets. Making frameworks is beyond
85the scope of this document.
86
87Note:
88It is rarely desirable to install non-Apple software into system directories.
89By configuring the library with --disable-shared and using the full path
90to wx-config with the --in-place option you can avoid installing the library.
91
92
93Apple Developer Tools: Xcode
94----------------------------
95
96You can use the project in src/wxWindows.xcodeproj to build wxWidgets,
97and there is a sample project supplied with the minimal sample.
98
99Notice that the command line build above builds not just the library itself but
100also wxrc tool which doesn't have its own Xcode project. If you need this tool,
101the simplest possibility is to build it from the command line after installing
102the libraries using commands like this:
103
104$ cd utils/wxrc
105$ g++ -o wxrc wxrc.cpp `wx-config --cxxflags --libs base,xml`
106
107Creating universal binaries
108---------------------------
109
110The Xcode projects for the wxWidgets library and minimal project are set up
111to create universal binaries.
112
113If using the Apple command line tools, pass --enable-universal_binary when
114configuring wxWidgets. This will create the libraries for all the supported
115architectures, currently ppc, i386 and x86_64 when using Cocoa (Carbon isn't
116available in 64 bit builds). You may explicitly specify the architectures to
117use as a comma-separated list, e.g. --enable-universal_binary=i386,x86_64.
118
119Notice that if you use wx-config --libs to link your application, the -arch
120flags are not added automatically as it is possible to link e.g. x86_64-only
121program to a "fat" library containing other architectures. If you want to
122build a universal application, you need to add the necessary "-arch xxx" flags
123to your project or makefile separately.
124
125As an alternative to using --enable-universal_binary, you can build for
126each architecture separately and then use the lipo tool to glue the
127binaries together. Assuming building on a PPC system:
128
1291. First build in the usual way to get the PPC library.
130
1312. Then, build for Intel, in a different folder. This time use:
132
133export CFLAGS="-g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386"
134export LDFLAGS="-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
135
136./configure --disable-dependency-tracking --enable-static=yes --enable-shared=no \
137 --target=i386-apple-darwin8 --host=powerpc-apple-darwin8 --build=i386-apple-darwin8
138
139You will need to reverse the powerpc and i386 parameters everywhere to build PPC on an Intel
140machine.
141
1423. Use lipo to glue the binaries together.
143
144See also:
145http://developer.apple.com/technotes/tn2005/tn2137.html
146
147