install.txt 5.8 KB

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