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