MacOS X ProjectBuilder Setup Guide

From WxWiki

Jump to: navigation, search

Contents

[edit] MacOS X ProjectBuilder Setup Guide

The wxWidgets for Mac port can be used with the GUI IDE, Project Builder (called XCode under OSX 10.3 and later). The library can be built using the supplied .pbproj file. However only one sample comes with a .pbproj file, the 'minimal' sample.

Here are two sets of notes on how to use Project Builder with wxWidgets. The second set are incomplete and were abandoned by the author, but may still be of use.

[edit] MacOS X Project Builder

Setting up Project Builder to compile a wxWidgets application is not difficult. Here is a possible way:

  • Start Project Builder.
  • File > New Project > Empty Project
  • Project > New Target > Application
  • Press the Targets tab and select the target you created
  • Under "GCC Compiler Settings" > "Other C Compiler Flags", paste the result from the "wx-config --cppflags" query made in the Terminal.
  • Under "Linker Settings" > "Other Mach-O Linker Flags", paste the result from the "wx-config --libs" query made in the Terminal.

Your wx project should compile now. If you are using the static wx library, you'll need the wx resource. Add these steps:

  • Still under "Linker Settings", make sure "Put Mac OS resources in:" is set to "Data fork of a separate .rsrc file".
  • Select your build style (eg, development or release), add another build setting called "OTHER_REZFLAGS" with the value "-srcIs DF" (that's a caps "i", not a low-caps "L").
  • Add "/usr/local/lib/libwx_mac-2.5.0.rsrc" to your files. I created a group called Resources and placed it there, so that PB knows that it is a resource. The path to this file may vary, depending on your installation.

[edit] MacOS X ProjectBuilder Setup Guide (NB: incomplete)

There are two main aspects to this guide: using ProjectBuilder to build the wxWidgets library itself, and using ProjectBuilder for your own project that uses the wxWidgets library. I'll address both of these and then show how the two can be combined into one project that facilitates easy source-level debugging.

Note that for builds that use this library to work properly, the mac-2.4 directory containing wx/setup.h must be found in the header file search path prior to any other wx/setup.h. This may require forcing the /usr/local/include to appear later in your project's search path, which may trigger a GCC warning ("changing search order for system directory.") This warning may be safely ignored; there does not seem to be a method to disable this specific warning at the moment. ProjectBuilder, however, seems to mistakenly count this warning as two errors, so you will have a mistakenly inflated count of errors when you are done compiling. This has another unfortunate side effect: ProjectBuilder will needlessly recompile these files in your project when you re-run the application, which is very time-consuming. If you have the entire wxWidgets library as a sub-project of your own project, to enable source-level debugging, this is intolerable because ProjectBuilder will attempt to recompile the entire wxWidgets library each time you launch the program.

-Wmost -Wno-four-char-constants -Wno-unknown-pragmas -Wno-long-double

You may also see "warning: redeclaration of C++ built-in type 'wchar_t'" which can also be safely ignored. Fortunately ProjectBuilder only counts this one as a warning.

last header search paths in library /usr/include

prefix header: /Users/potts/Documents/sandbox-wx/wxWidgets/include/wx_pb.h

(No more written -- if anyone would like to add more, please do)

[edit] Problems

I always got the message ''Illegal reference to zlib'' (or sth. like that) when linking the static library. Adding the option '''-lz''' to "Targets > Settings > Linker Settings > Other Mach-O Linker Flags" helped me. -lz (this is a lower case ''L'') forces linking to zlib.

Personal tools