1 | README.OSX.txt - 2010-10-23 - Building FLTK under Apple OS X |
---|
2 | ------------------------------------------------------------ |
---|
3 | |
---|
4 | |
---|
5 | |
---|
6 | CONTENTS |
---|
7 | ========== |
---|
8 | |
---|
9 | 1 INTRODUCTION |
---|
10 | 2 HOW TO BUILD FLTK USING GCC |
---|
11 | 2.1 Prerequisites |
---|
12 | 2.2 Downloading and Unpacking |
---|
13 | 2.3 Configuring FLTK |
---|
14 | 2.4 Building FLTK |
---|
15 | 2.5 Testing FLTK |
---|
16 | 2.6 Installing FLTK |
---|
17 | 2.7 Creating new Projects |
---|
18 | 3 HOW TO BUILD FLTK USING XCODE3 |
---|
19 | 3.1 Prerequisites |
---|
20 | 3.2 Downloading and Unpacking |
---|
21 | 3.3 Configuring FLTK |
---|
22 | 3.4 Building FLTK |
---|
23 | 3.5 Testing FLTK |
---|
24 | 3.6 Uninstalling previous versions of FLTK |
---|
25 | 3.7 Installing FLTK |
---|
26 | 3.8 Installing Little Helpers |
---|
27 | 3.9 Creating new Projects |
---|
28 | 4 DOCUMENT HISTORY |
---|
29 | |
---|
30 | |
---|
31 | 1 INTRODUCTION |
---|
32 | ================= |
---|
33 | |
---|
34 | FLTK currently supports the following development environments on the Apple OS X |
---|
35 | platform: |
---|
36 | |
---|
37 | - gcc command line tools |
---|
38 | - Xcode 3.x |
---|
39 | |
---|
40 | CAUTION: gcc command line built libraries and Xcode created Frameworks should |
---|
41 | not be mixed! |
---|
42 | |
---|
43 | |
---|
44 | 2 HOW TO BUILD FLTK USING GCC |
---|
45 | ================================ |
---|
46 | |
---|
47 | |
---|
48 | 2.1 Prerequisites |
---|
49 | -------------------- |
---|
50 | |
---|
51 | In order to build FLTK from the command line, you need to install the Xcode |
---|
52 | developer environment from the Apple Inc. web site. The developer environment |
---|
53 | can be downloaded from the Mac Dev Center for free: |
---|
54 | |
---|
55 | http://developer.apple.com/technologies/xcode.html |
---|
56 | |
---|
57 | After downloading and installing, you need to launch the Terminal. Terminal.app |
---|
58 | is located in the "Utilities" folder inside the "Applications" folder. I like to |
---|
59 | keep the Terminal in the Dock. |
---|
60 | |
---|
61 | |
---|
62 | 2.2 Downloading and Unpacking |
---|
63 | -------------------------------- |
---|
64 | |
---|
65 | Download FLTK from here: |
---|
66 | |
---|
67 | http://www.fltk.org/software.php |
---|
68 | |
---|
69 | If you are familiar with "subversion" and like to stay current with your |
---|
70 | version, you will find the subversion access parameters at the bottom of that |
---|
71 | page. Unpack FLTK into a convinient location. I like to have everything in my |
---|
72 | dev directory: |
---|
73 | |
---|
74 | cd |
---|
75 | mkdir dev |
---|
76 | cd dev |
---|
77 | mv ~/Downloads/fltk-1.3.xxxx.tar.gz . |
---|
78 | tar xvfz fltk-1.3.xxxx.tar.gz |
---|
79 | cd fltk-1.3.xxxx |
---|
80 | |
---|
81 | |
---|
82 | 2.3 Configuring FLTK |
---|
83 | ----------------------- |
---|
84 | |
---|
85 | Stay in your FLTK source-code directory. Type: |
---|
86 | |
---|
87 | autoconf |
---|
88 | |
---|
89 | Now configure your FLTK installation: |
---|
90 | |
---|
91 | ./configure |
---|
92 | |
---|
93 | ADVANCED: type "./configure --help" to get a complete list of optional |
---|
94 | configurations parameters. These should be pretty self-explanatory. Some |
---|
95 | more details can be found in README. |
---|
96 | |
---|
97 | To create Universal Binaries, start "configure" with these flags: |
---|
98 | ./configure --with-archflags="-arch i386 -arch ppc -arch x86_64" |
---|
99 | :END_ADVANCED |
---|
100 | |
---|
101 | The configuration script will check your machine for the required resources |
---|
102 | which should all have been part of your Xcode installation. Review the |
---|
103 | Configuration Summary, maybe take some notes. |
---|
104 | |
---|
105 | |
---|
106 | 2.4 Building FLTK |
---|
107 | -------------------- |
---|
108 | |
---|
109 | Now this is easy. Stay in your FLTK source-code directory and type: |
---|
110 | |
---|
111 | make |
---|
112 | |
---|
113 | The entire FLTK toolkit including many test programs will be built for you. No |
---|
114 | warnings should appear, but "ranlib" may complain about a few modules having no |
---|
115 | symbols. This is normal and can safely be ignored. |
---|
116 | |
---|
117 | |
---|
118 | 2.5 Testing FLTK |
---|
119 | ------------------- |
---|
120 | |
---|
121 | After a successful build, you can test FLTK's capabilities: |
---|
122 | |
---|
123 | test/demo |
---|
124 | |
---|
125 | |
---|
126 | 2.6 Installing FLTK |
---|
127 | ---------------------- |
---|
128 | |
---|
129 | If you did not change any of the configuration settings, FLTK will be installed |
---|
130 | in "/usr/local/include" and "/usr/local/lib" by typing |
---|
131 | |
---|
132 | sudo make install |
---|
133 | |
---|
134 | It is possible to install FLTK without superuser privileges by changing the |
---|
135 | installation path to a location within the user account by adding the |
---|
136 | "--prefix=PREFIX" parameter to the "./configure" command. |
---|
137 | |
---|
138 | |
---|
139 | 2.7 Creating new Projects |
---|
140 | ---------------------------- |
---|
141 | |
---|
142 | FLTK provides a neat script named "fltk-config" that can provide all the flags |
---|
143 | needed to build FLTK applications using the same flags that were used to build |
---|
144 | the library itself. Architecture flags (e.g., -arch i386) used to build the |
---|
145 | library, though, are not provided by the fltk-config script. This allows to |
---|
146 | build universal libraries and to produce applications of any architecture |
---|
147 | from them. Running "fltk-config" without arguments will print a list |
---|
148 | of options. The easiest call to compile an FLTK application from a single source |
---|
149 | file is: |
---|
150 | |
---|
151 | fltk-config --compile myProgram.cxx |
---|
152 | |
---|
153 | "fltk-config" and "fluid" will be installed in "/usr/local/bin/" by default. I |
---|
154 | recommend that you add it to the command search path. |
---|
155 | |
---|
156 | |
---|
157 | |
---|
158 | 3 HOW TO BUILD FLTK USING XCODE3 |
---|
159 | =================================== |
---|
160 | |
---|
161 | |
---|
162 | 3.1 Prerequisites |
---|
163 | -------------------- |
---|
164 | |
---|
165 | In order to build FLTK from within Xcode, you need to install the Xcode |
---|
166 | developer environment from the Apple Inc. web site. The developer environment |
---|
167 | can be downloaded from the Mac Dev Center for free: |
---|
168 | |
---|
169 | http://developer.apple.com/technologies/xcode.html |
---|
170 | |
---|
171 | |
---|
172 | 3.2 Downloading and Unpacking |
---|
173 | -------------------------------- |
---|
174 | |
---|
175 | Download FLTK from here: |
---|
176 | |
---|
177 | http://www.fltk.org/software.php |
---|
178 | |
---|
179 | If you are familiar with "subversion" and like to stay current with your |
---|
180 | version, you will find the subversion access parameters at the bottom of that |
---|
181 | page. You can use the SCM system that is built into Xcode. |
---|
182 | |
---|
183 | Unpack FLTK by double-clicking it and copy the new folder into a convenient |
---|
184 | location. I have set up a "dev" folder in my home folder for all my projects. |
---|
185 | |
---|
186 | |
---|
187 | 3.3 Configuring FLTK |
---|
188 | ----------------------- |
---|
189 | |
---|
190 | Launch Xcode. Open the project file in |
---|
191 | |
---|
192 | .../fltk-1.3.xxxx/ide/Xcode3/FLTK.xcodeproj |
---|
193 | |
---|
194 | Use the "Project" pulldown menu to change "Active Build Configuration" to |
---|
195 | "Release". Change the "Active Architecture" as desired. |
---|
196 | |
---|
197 | |
---|
198 | 3.4 Building FLTK |
---|
199 | -------------------- |
---|
200 | |
---|
201 | Use the "Project" pulldown menu to set the "Active Target" to "Demo". |
---|
202 | Select "Build" from the "Build" menu to create all libraries and test applications. |
---|
203 | |
---|
204 | All frameworks and apps will be located in "./ide/Xcode3/build/Release/". |
---|
205 | |
---|
206 | |
---|
207 | 3.5 Testing FLTK |
---|
208 | ------------------- |
---|
209 | |
---|
210 | Select "Build and Run" from the "Build" menu to run the Demo program. Use "Demo" |
---|
211 | to explore all test programs. |
---|
212 | |
---|
213 | |
---|
214 | 3.6 Uninstalling previous versions of FLTK |
---|
215 | --------------------------------------------- |
---|
216 | |
---|
217 | Remove FLTK frameworks: |
---|
218 | |
---|
219 | sudo rm -r /Library/Frameworks/fltk*.framework |
---|
220 | |
---|
221 | Remove Fluid and possibly other utilities: |
---|
222 | |
---|
223 | sudo rm -r /Developer/Applications/Utilities/FLTK/ |
---|
224 | |
---|
225 | |
---|
226 | 3.7 Installing FLTK |
---|
227 | ---------------------- |
---|
228 | |
---|
229 | When distributing FLTK applications, the FLTK frameworks should be made part of |
---|
230 | the application package. For development however, it is very convenient to have |
---|
231 | the Release-mode Frameworks in a standard location. |
---|
232 | |
---|
233 | For Xcode project template use, all FLTK frameworks should be copied from |
---|
234 | "./ide/Xcode3/build/Release/" to "/Library/Frameworks/". The FLTK header files |
---|
235 | for all FLTK frameworks will then be at "/Library/Frameworks/fltk.framework/ |
---|
236 | Headers/". Add this path to the header search path of your projects. |
---|
237 | |
---|
238 | sudo rm -f -r /Library/Frameworks/fltk* |
---|
239 | sudo cp -R ide/Xcode3/build/Release/fltk*.framework /Library/Frameworks/ |
---|
240 | |
---|
241 | Many FLTK applications will use Fluid, the FLTK User Interface builder, to |
---|
242 | generate C++ source code from .fl resource files. Add Fluid to the developer |
---|
243 | tools: |
---|
244 | |
---|
245 | sudo mkdir /Developer/Applications/Utilities/FLTK/ |
---|
246 | sudo rm -f -r /Developer/Applications/Utilities/FLTK/Fluid.app |
---|
247 | sudo cp -R ide/Xcode3/build/Release/Fluid.app /Developer/Applications/Utilities/FLTK/ |
---|
248 | |
---|
249 | |
---|
250 | 3.8 Installing Little Helpers |
---|
251 | -------------------------------- |
---|
252 | |
---|
253 | |
---|
254 | - Project Templates: |
---|
255 | |
---|
256 | Project Templates are the quickest way to create a new FLTK application from |
---|
257 | within Xcode. The included project builds an FLTK based Cocoa application |
---|
258 | written in C++ with support for the Fluid UI designer, image reading, and |
---|
259 | OpenGL. Unused FLTK sub-Frameworks can simply be removed from the project. |
---|
260 | The template assumes that Release versions of the FLTK frameworks are installed |
---|
261 | in /Library/Frameworks as described above. |
---|
262 | |
---|
263 | First, we need to create the Template folder: |
---|
264 | |
---|
265 | sudo mkdir -p /Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/ |
---|
266 | |
---|
267 | Next, we copy the project template over: |
---|
268 | |
---|
269 | sudo cp -r ide/Xcode3/Project\ Templates/* /Library/Application\ Support/Developer/Shared/Xcode/Project\ Templates/ |
---|
270 | |
---|
271 | After restarting Xcode, the dialog for "File > New Project..." will offer an |
---|
272 | FLTK 1.3 user template which is ready to compile. |
---|
273 | |
---|
274 | |
---|
275 | - Fluid file handling |
---|
276 | |
---|
277 | This section assumes that a Release version of Fluid is installed in |
---|
278 | "/Developer/Applications/Utilities/FLTK/" as described above. It will install |
---|
279 | a new file type which opens Fluid as an editor for files ending in ".fl". |
---|
280 | |
---|
281 | First, we need to create the spec folder: |
---|
282 | |
---|
283 | sudo mkdir -p /Library/Application\ Support/Developer/Shared/Xcode/Specifications/ |
---|
284 | |
---|
285 | Next, we copy the Fluid specification over: |
---|
286 | |
---|
287 | sudo cp ide/Xcode3/fluid.pbfilespec /Library/Application\ Support/Developer/Shared/Xcode/Specifications/ |
---|
288 | |
---|
289 | Open Xcode preferences and select the File Types tab. Find the |
---|
290 | "sourcecode.fluid" entry in "file > text > sourcecode" and set the external |
---|
291 | editor to Fluid. When adding ".fl" files, set the File Type in the Info dialog |
---|
292 | to "sourcecode.fluid" and Xcode will edit your file in Fluid when |
---|
293 | double-clicking. |
---|
294 | |
---|
295 | |
---|
296 | - More |
---|
297 | |
---|
298 | TODO: Language Definition |
---|
299 | TODO: Build Rules |
---|
300 | |
---|
301 | |
---|
302 | 3.9 Creating new Projects |
---|
303 | ---------------------------- |
---|
304 | |
---|
305 | If the little helpers above were installed, the menu "File > New Project..." |
---|
306 | will pop up a dialog that offers a User Template named Fluid. Select it and |
---|
307 | follow the instructions. |
---|
308 | |
---|
309 | |
---|
310 | |
---|
311 | 4 DOCUMENT HISTORY |
---|
312 | ===================== |
---|
313 | |
---|
314 | Oct 29 2010 - matt: removed warnings |
---|
315 | Oct 24 2010 - matt: restructured entire document and verified instructions |
---|
316 | Dec 19 2010 - Manolo: corrected typos |
---|
317 | Dec 29 2010 - Manolo: removed reference to AudioToolbox.framework that's no longer needed |
---|
318 | Feb 24 2011 - Manolo: architecture flags are not propagated to the fltk-config script. |
---|