]> git.saurik.com Git - wxWidgets.git/blob - docs/osx/install.txt
Define __VISUALC__ for ICC under Windows again.
[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 For Carbon, you'll need to have Xcode 3.x installed (you can also have Xcode 4.x
23 installed, but the Carbon build needs 3.x, and the /Developer directory which is
24 installed when you install Xcode 3.x.
25
26 ---------
27
28 # Build the library for Cocoa (wxWidgets 2.9.0 and later)
29 mkdir build-cocoa-debug
30 cd build-cocoa-debug
31 ../configure --with-osx_cocoa --enable-debug
32 make
33 # Build the samples and demos
34 cd samples; make;cd ..
35 cd demos; make;cd ..
36
37 ---------
38
39 # Build the library for Carbon
40 mkdir build-carbon-debug
41 cd 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
43 make
44 # Build the samples and demos
45 cd samples;make;cd ..
46 cd demos; make;cd ..
47
48 ---------
49
50 After 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.
55 Double-click on the executables which have an icon showing three small squares.
56 The source code for the samples is in wxWidgets/samples
57 The source code for the demos is in wxWidgets/demos
58
59 ---------
60
61 More information about building on Mac OS X is available in the wxWiki.
62 Here are two useful links
63 http://wiki.wxwidgets.org/Guides_%26_Tutorials
64 http://wiki.wxwidgets.org/Development:_wxMac
65
66 ---------
67
68 More advanced topics are covered below.
69
70 ---------
71
72 If you want to install the library into the system directories you'll need
73 to do this as root. The accepted way of running commands as root is to
74 use the built-in sudo mechanism. First of all, you must be using an
75 account marked as a "Computer Administrator". Then
76
77 6) sudo make install
78 7) type <YOUR OWN PASSWORD>
79
80 Note that while using this method is okay for development, it is not
81 recommended that you require endusers to install wxWidgets into their
82 system directories in order to use your program. One way to avoid this
83 is to configure wxWidgets with --disable-shared. Another way to avoid
84 it is to make a framework for wxWidgets. Making frameworks is beyond
85 the scope of this document.
86
87 Note:
88 It is rarely desirable to install non-Apple software into system directories.
89 By configuring the library with --disable-shared and using the full path
90 to wx-config with the --in-place option you can avoid installing the library.
91
92
93 Apple Developer Tools: Xcode
94 ----------------------------
95
96 You can use the project in src/wxWindows.xcodeproj to build wxWidgets,
97 and there is a sample project supplied with the minimal sample.
98
99 Notice that the command line build above builds not just the library itself but
100 also wxrc tool which doesn't have its own Xcode project. If you need this tool,
101 the simplest possibility is to build it from the command line after installing
102 the libraries using commands like this:
103
104 $ cd utils/wxrc
105 $ g++ -o wxrc wxrc.cpp `wx-config --cxxflags --libs base,xml`
106
107 Creating universal binaries
108 ---------------------------
109
110 The Xcode projects for the wxWidgets library and minimal project are set up
111 to create universal binaries.
112
113 If using the Apple command line tools, pass --enable-universal_binary when
114 configuring wxWidgets. This will create the libraries for all the supported
115 architectures, currently ppc, i386 and x86_64 when using Cocoa (Carbon isn't
116 available in 64 bit builds). You may explicitly specify the architectures to
117 use as a comma-separated list, e.g. --enable-universal_binary=i386,x86_64.
118
119 Notice that if you use wx-config --libs to link your application, the -arch
120 flags are not added automatically as it is possible to link e.g. x86_64-only
121 program to a "fat" library containing other architectures. If you want to
122 build a universal application, you need to add the necessary "-arch xxx" flags
123 to your project or makefile separately.
124
125 As an alternative to using --enable-universal_binary, you can build for
126 each architecture separately and then use the lipo tool to glue the
127 binaries together. Assuming building on a PPC system:
128
129 1. First build in the usual way to get the PPC library.
130
131 2. Then, build for Intel, in a different folder. This time use:
132
133 export CFLAGS="-g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386"
134 export 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
139 You will need to reverse the powerpc and i386 parameters everywhere to build PPC on an Intel
140 machine.
141
142 3. Use lipo to glue the binaries together.
143
144 See also:
145 http://developer.apple.com/technotes/tn2005/tn2137.html
146
147