Installing On MacOS X Using Apple's Developer Tools

From WxWiki

Jump to: navigation, search

[edit] MacOS X (with Apple's Developer Tools)

Please note that this article is outdated and incompelte. For up-to-date information, please see Mac OS X And Xcode For Beginners

This process has last been tested with Apple's developer tools that include GCC 3.1. There are known problems with the later 3.3 release. (This was true for wxWidgets 2.4.1. More recent versions, like wxWidgets 2.6.3 and 2.7.0 build without any problem with gcc 3.3)

To see what version of GCC your system is using, type gcc --version. Mine is:

gcc (GCC) 3.1 20020420 (prerelease)

If you are using 3.3, you may be able to set the GCC version back to 3.1 (globally) using

sudo /usr/sbin/gcc_select 3.1

You have several choices: you can build the library using the command-line tools, or using the supplied ProjectBuilder project.

%projectbuilder The ProjectBuilder approach has been undergoing a number of fixes. For ease in source-level debugging using ProjectBuilder you can also include the library in the ProjectBuilder project you use for your application. I (Paul R. Potts, <paul@thepottshouse.org> am working on an example). %%

The basic procedure for building with the command-line tools is outlined here. The standard install will place libraries in /usr/local/lib, standard wxWidgets headers in /usr/local/include, and the generated setup.h under /usr/local/lib/ (this last piece is a common source of confusion).

You may find it easiest to begin with the 2.4.1 source, since the CVS version is changing rapidly. If you can get the 2.4.1 source built, your development tools are working correctly and you understand the basic process. From there, if you have difficulty with the CVS head, you can discuss them on the wx-users mailing list.

%2.4.1 with command-line tools 1. move to the wxMac-2.4.1 directory.

2. mkdir macbuild

3. ../configure (There are many options you can give to the configure script. The defaults will give you a shared library with debugging disabled).

4. make

You might experience compilation error on dc.cpp g++ -c -I./lib/wx/include/mac-2.4 -I../include -I../src/png -I../src/jpeg -I../src/tiff -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -no-cpp-precomp -fpascal-strings -I../src/mac/morefile -I/Developer/Headers/FlatCarbon -D__WXMAC__ -DWXMAKINGDLL -O2 -MMD -fno-common -Wall -dynamic -fPIC -o dc.o ../src/mac/dc.cpp ../src/mac/dc.cpp:1259: parse error before `<<' token ../src/mac/dc.cpp:1263: parse error before `short' make: *** [dc.o] Error 1

To fix the problem apply the difference highlighted in green (in this link) in the source code of dc.cpp http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/src/mac/dc.cpp.diff?r1=1.56.2.11&r2=1.56.2.12

then relaunch

make

5. sudo make install %%

Verify that you now have:

in /usr/local/lib:

libwx_mac-2.4.0.0.0.dylib (with a number of symlinks for different version numbers)

libwx_mac-2.4.0.rsrc

libwx_mac-2.4.r

/wx/include/mac-2.4/wx/setup.h

/wx/include/univ/wx/wx/setup.h

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. You may also see "warning: redeclartion of C++ built-in type 'wchar_t'" which can also be safely ignored. Fortunately ProjectBuilder only counts this one as a warning.

You should also have the standard 2.4.1 include files in

/usr/local/include/wx

If everything seems to be in order, you should be able to build one of the samples:

%2.4.1 with command-line tools 6. cd ./samples/widgets

7. make

8. open ./widgets.app %%

For more detailed notes for working with 2.5 from CVS (see Building WxWidgets With MacOS X) and for working with ProjectBuilder (see MacOS X ProjectBuilder Setup Guide).

Personal tools