Applied #12985: Improved installation instructions for wxWidgets for Mac OS X Cocoa...
[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 --enable-unicode --enable-debug --disable-shared --with-osx_cocoa
28 make;cd ..
29 # Build the samples and demos
30 cd build-cocoa-debug/samples; make;cd ../..
31 cd build-cocoa-debug/demos;   make;cd ../..
32
33 ---------
34
35 # Build the library for Carbon
36 mkdir build-carbon-debug
37 cd build-carbon-debug
38 ../configure --enable-unicode --enable-debug --disable-shared
39 make;cd ..
40 # Build the samples and demos
41 cd build-carbon-debug/samples;make;cd ../..
42 cd build-carbon-debug/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 We recommend you configure a static library instead:
85
86 4) ../configure --disable-shared
87
88 or activate OpenGL:
89
90 4) ../configure --with-opengl
91
92 Note:
93 It is rarely desirable to install non-Apple software into system directories.
94 By configuring the library with --disable-shared and using the full path
95 to wx-config with the --in-place option you can avoid installing the library.
96
97
98 Apple Developer Tools: Xcode
99 ----------------------------
100
101 You can use the project in src/wxWindows.xcodeproj to build wxWidgets,
102 and there is a sample project supplied with the minimal sample.
103
104 Notice that the command line build above builds not just the library itself but
105 also wxrc tool which doesn't have its own Xcode project. If you need this tool,
106 the simplest possibility is to build it from the command line after installing
107 the libraries using commands like this:
108
109 $ cd utils/wxrc
110 $ g++ -o wxrc wxrc.cpp `wx-config --cxxflags --libs base,xml`
111
112 Creating universal binaries
113 ---------------------------
114
115 The Xcode projects for the wxWidgets library and minimal project are set up
116 to create universal binaries.
117
118 If using the Apple command line tools, pass --enable-universal_binary when
119 configuring wxWidgets. If you use wx-config --libs to link your application,
120 he necessary linker flags will be added. When compiling your own files,
121 you need to add -arch ppc -arch i386 to your CFLAGS.
122
123 As an alternative to using --enable-universal_binary, you can build for
124 each architecture separately and then use the lipo tool to glue the
125 binaries together. Assuming building on a PPC system:
126
127 1. First build in the usual way to get the PPC library.
128
129 2. Then, build for Intel, in a different folder. This time use:
130
131 export CFLAGS="-g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386"
132 export LDFLAGS="-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
133
134 ./configure --disable-dependency-tracking --enable-static=yes --enable-shared=no \
135   --target=i386-apple-darwin8 --host=powerpc-apple-darwin8 --build=i386-apple-darwin8
136
137 You will need to reverse the powerpc and i386 parameters everywhere to build PPC on an Intel
138 machine.
139
140 3. Use lipo to glue the binaries together.
141
142 See also:
143 http://developer.apple.com/technotes/tn2005/tn2137.html
144
145