README.OSX.txt 15 KB

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