Installation on Mac OS X

HippoDraw can be built from source as either a X11 or native (Cocoa) application.

It depends on whether the Qt library you use was built with X11 or native windows. In either case either Qt 3 or Qt 4 can be used.

Since HippoDraw is a cross-platform application built with Qt support, There are some special precautions and steps that need to be taken on the Mac OS X platform. This page collects these steps that are particular to that platorm. Of course, a build can fail in ways it fails on other Unix like systems as well. See Unix like System, Linux, Solaris, etc. for appropriate notes.

Installing Qt

The first decision is whether you want to build HippoDraw as a native (Cocoa) or as a X11 application. If X11, one can get pre-built Qt binaries from fink . With this release, fink has Qt-3.3.4 built with gcc 3.3. See Using older gcc for building. for information on building HippoDraw with same version of gcc.

If you want a native (Cocoa) version of HippoDraw, than you'll first need to build and install a version of Qt. The current version is available from Trolltech's web page. Older versions can be fround on the ftp.trolltech.com server. You can choose between Qt 3 and Qt 4. The installation is sligthly different and described in the following sections.

Installing Qt3

Building Qt 3 from source is fairly easy and the instructions in Qt's INSTALL file work. However, one needs to add at least one option to the configure command. HippoDraw requires Qt with thread support if it is to be used as Python extension module. A typical build of Qt 3 is thus

> configure -thread -qt-gif
> make

After building, follow the instructins in the INSTALL file if you want to avoid using DYLD_LIBRARY_PATH for applications based on Qt to work. Namely, HippoDraw was tested on the Mac after doing ...

> ln -sf $QTDIR/lib/libqt-mt.3.dylib /usr/lib
> ln -sf $QTDIR/lib/libqui.1.dylib /usr/lib

Installing Qt4

The installationo procedure for Qt 4 has more support for the Mac OS X system then with Qt 3.

As describled in the Qt 4 INSTALL file, QT 4 is built by default as a Mac OS framework. Using frameworks would make HippoDraw's Makefiles incompatible with other UNIX platforms. Thus development of HippoDraw on the Mac is done without Qt as a framework. For the build of Qt 4, HippoDraw developers used the following configure command

> configure -qt-gif -no-framework -universal -sdk /Developer/SDKs/MacOSX10.5.sdk -release
>

Note in the above configure example we built Qt as universal binaries. Also we found that the -release is necessary otherwise QT is built with both release and debug versions.

Building HippoDraw

Once a version of Qt has been installed, HippoDraw builds on the Mac like it builds on any other Unix-like system. See Installation for more information. However, some of the optional external libraries have minor problems on Mac OS X for various reasons. They are discussed below.

Building WCSlib

Installing the optional World CoordinateSystem library (WCSLIB) (optional) version 4.2 has the following compilation errors on Mac OS X 10.4.6

gcc -DHAVE_CONFIG_H -g -O2 -c wcsulex.c
In file included from lex.wcsulex.c:8848:
/usr/include/unistd.h:441: error: conflicting types for 'read'
lex.wcsulex.c:8523: error: previous implicit declaration of 'read' was here
make[2]: *** [wcsulex.o] Error 1

gcc -DHAVE_CONFIG_H -g -O2 -c wcsutrn.c
In file included from lex.wcsutrn.c:5103:
/usr/include/unistd.h:441: error: conflicting types for 'read'
lex.wcsutrn.c:4793: error: previous implicit declaration of 'read' was here
make[2]: *** [wcsutrn.o] Error 1
make[2]: Target `lib' not remade because of errors.
make[1]: *** [../C/libwcs-4.2.a] Error 2

The problems appears to be that files wcsulex.c and wcsutrn.c were generated by a flex incompatible with the unistd.h file on Darwin. The fix is to touch the files wcsulex.l and wcsutrn.l to change their file dates. Then when you issue make, the Darwin flex will be used to reproduce these files and they can compile.

But you're not done yet. make install fails like this

> sudo make install
Password:
make -k -C pgsbox install

fc  -I../FORTRAN -c -o pgsbox.o pgsbox.f
/usr/bin/fc: line 4: fc: -I: invalid option
fc: usage: fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
make[1]: *** [pgsbox.o] Error 2

fc  -I../FORTRAN -c -o pgcrfn.o pgcrfn.f
/usr/bin/fc: line 4: fc: -I: invalid option
fc: usage: fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
make[1]: *** [pgcrfn.o] Error 2
make[1]: Target `install' not remade because of errors.
make: *** [install] Error 2

The configure script thought there was a Fortran compiler available because it found /usr/bin/fc, the script to drive f2c as a Fortran compiler. But f2c is not in Darwin. The fix to this problem is

> cd C
> sudo make install
Password:
/usr/bin/install -c -d -m 2755 /usr/local/lib
/usr/bin/install -c -m 644 libwcs-4.2.a /usr/local/lib
rm -f /usr/local/lib/libwcs.a
ln -s /usr/local/lib/libwcs-4.2.a /usr/local/lib/libwcs.a
/usr/bin/install -c -d -m 2755 /usr/local/include/wcslib-4.2
/usr/bin/install -c -m 444 CHANGES /usr/local/include/wcslib-4.2/CHANGES_C
/usr/bin/install -c -m 444 *.h /usr/local/include/wcslib-4.2
rm -f /usr/local/include/wcslib
ln -s /usr/local/include/wcslib-4.2 /usr/local/include/wcslib

That is go to the C directory and issue make install there. But you're still not done. Notice in the above, that ranlib wasn't run on the installed static library. So the last step is

> sudo ranlib /usr/local/lib/libwcs.a

Building from CVS checkout

If you are building from source code obtained via anonymous ftp from the .tar.gz file, this section does not apply.

For Mac OS X version 10.5 and later, an up to date version of GNU autoconf and GNU automake are part of the standard developer's environment. However, the libtool command has nothing to do with GNU libtool. The GNU libtool is hidden as the commands glibtool and its companion glibtoolize. However. this version still needs patching (Linking main on Mac OS X fails.). The workaround for these problems is detected by the autogen script. The script will apply the required patch.

Failing to find Qt.

Using the fink version of Qt, one might get the following output from configure

checking for Qt... yes:
    QT_CXXFLAGS=-I/sw/lib/qt3/include -DQT_THREAD_SUPPORT
    QT_DIR=/sw/lib/qt3
    QT_LIBS=-L/sw/lib/qt3/lib -lqt-mt  -lSM -lICE \
 -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi
    QT_UIC=/sw/lib/qt3/bin/uic
    QT_MOC=/sw/lib/qt3/bin/moc
checking correct functioning of Qt installation... failure
configure: error: Failed to find matching components of a complete
                  Qt installation. Try using more options,
                  see ./configure --help.

There are several reasons the configure script could fail to find Qt. The most frequent error is that Qt was not built with thread support. One can look at the config.log file to see what the error really was. One can copy the last command from the config.log file and paste into the shell window to get more details, as was done below.

ki-mac06:~/hippodraw-BUILD pfkeb$  g++ -L/sw/lib/qt3/lib -lqt-mt  -lSM -lICE \
-L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi   -o bnv_qt_main bnv_qt_main.o \
moc_bnv_qt_test.o
/usr/bin/ld: Undefined symbols:
typeinfo for QPtrCollection
typeinfo for QObject
collect2: ld returned 1 exit status

In this case, Qt from fink was built with gcc 3.3 while configure was using gcc 4.0.1.

See also:
Using older gcc for building..

Using older gcc for building.

HippoDraw can be built with just about any available version of gcc. The default compiler for Mac OS X 10.4 (tiger) is gcc 4.0.1. However, if you want to build HippoDraw using external libraries from fink that were compiled with gcc 3.3, you need to make that version of gcc the default compiler. This is done by issueing the following command as root

> gcc_select 3.3

Beware that this changes the default compiler for all users and all future uses on the system. So after building HippoDraw you probably want to change it back by issueing the same command with `4.0' instead of `3.3'.

Failing to find Boost.Python libraries

A second problem is that the Boost library name is different than the default. On most UNIX systems (including Linux), gcc is part of the library name when the GCC compiler is used. On Mac OS X, even though GCC is the compiler, gcc is not part of the library name. Thus, you need to configure the Boost options something like this


bartok:~/hippodraw-BUILD pfkeb$ ../hippodraw/configure
--with-Qt-dir=$HOME/qt --with-boost-libname=boost_python-1_33_1

Installing Boost on Mac OS X

One builds boost on Mac OS X like any other Unix like system. The configure, make, make install works (see Installing Boost). Howver, if you want issue the bjam command yourself, you must specify the Python root directory explicitly like this

export PYTHON_VERSION=2.3
bjam --with-python-root=/System/Library/Frameworks/Python.framework/Versions/2.3 \
"-sTOOLS=darwin" install

If you do not do this, then Python root directory is taken as /usr because /usr/bin/python is in your execution path.

Linking libhippo on Mac OS X fails

ld: .libs/libhippo.lax/libbinners.a/BinnerAxisLog.o malformed object, \
illegal reference for -dynamic code (reference to a coalesced section \
(__TEXT,__textcoal_nt) from section (__TEXT,__eh_frame) relocation entry (0))

This error appears to have been a result of other failures. The fix seems to do

> make clean
> make

One might even need to go back to the configure step to clear up this problem.

Failing to link with libqassistantclient.a

If you get this error
ld: table of contents for archive:
/sw/lib/qt3/lib/libqassistantclient.a is out of date; rerun ranlib(1)
(can't load from it) 
It probably means that you need to run ranlib on this archive library. Fro example, this library as it comes with fink needs to have this done after the install.

Linking main on Mac OS X fails.

If you are obtaining the sources from CVS and have trouble linking the main with an error message like this...


/bin/sh ../libtool --mode=link g++  -g -O2 -Wall   -o hippodraw \
-R /usr/local/lib    -R /usr/lib  main.o libhippoqt.la
libtool: link: cannot find the library `'

then libtool is not handling the Mac OS X frameworks correctly. A patch for libtool 1.5 available from http://ranger.befunk.com/patches/libtool-framework.patch which I have copied to config/libtool-framework.patch. I did the following to patch the file after doing a "autogen" in the top level source directory.

> cd config
> rm ltmain.sh
> cp /sw/share/libtool/ltmain.sh .
> patch ltmain.sh libtool-framework.patch

Alternatively, after the qt/libhippoqt.la has been created, edit the line

dependency_libs=' -R/Users/pfkeb/qt/lib  -L/Users/pfkeb/qt/lib
/Users/pfkeb/qt/lib/libqt-mt.la -lz Carbon QuickTime OpenGL -framework AGL'

so that it looks like

dependency_libs=' -R/Users/pfkeb/qt/lib  -L/Users/pfkeb/qt/lib
/Users/pfkeb/qt/lib/libqt-mt.la'

Be aware that your changes will be wiped out the next time a link is done in the qt directory.

Build Qt failed in linking moc

if you see an error in building Qt like the following...
c++ -headerpad_max_install_names /Users/pfkeb/qt-mac-free-3.3.6/lib -prebind \
-o ../../bin/moc ./qbuffer.o ./qptrcollection.o ./qcstring.o ./qdatastream.o \
./qdatetime.o ./qfile.o ./qdir.o ./qfileinfo.o ./qgarray.o ./qgdict.o \
./qglist.o ./qglobal.o ./qgvector.o ./qiodevice.o ./qregexp.o ./qstring.o \
./qlocale.o ./qunicodetables.o ./qstringlist.o ./qtextstream.o ./qbitarray.o \
./qmap.o ./qgcache.o ./qtextcodec.o ./qutfcodec.o ./moc_yacc.o ./qfile_unix.o \
./qdir_unix.o ./qfileinfo_unix.o     -framework Carbon
/usr/bin/ld: can't map file: /Users/pfkeb/qt-mac-free-3.3.6/lib ((os/kern) \
invalid argument)
collect2: ld returned 1 exit status
make[2]: *** [../../bin/moc] Error 1
make[1]: *** [src-moc] Error 2
make: *** [init] Error 2

One gets this error if one tried the -R options when configuring Qt. This option doesn't appear to work as advertised on a Mac. Try leaving it off and depend on QTDIR being set when compiling HippoDraw.

Make install fails

If su make install fails like this

( cd ../python/.libs; pydoc -w hippo )
problem in hippo - ImportError: dlopen(./hippomodule.so, 2): Library not loaded: libqt-mt.3.dylib
  Referenced from: ./hippomodule.so
  Reason: image not found
mv ../python/.libs/hippo.html html/.
mv: rename ../python/.libs/hippo.html to html/./hippo.html: No such file or directory
make[3]: *** [pydocs] Error 1
make[2]: *** [install-am] Error 2
make[1]: *** [install-recursive] Error 1
make: *** [install-recursive] Error 1
k

It is because DYLD_LIBRARY_PATH is not set with the path to the Qt shared libraries. This can happen even if this enirnoment variable is set properly in the users environment. Apparently, root user does not inherit this variable, even thought it inherits others (a feature?). The obvious workaround is to use sudo to become root and set the variable manually like this

ki-mac03: pfkeb$ sudo su
Password:
ki-mac03: root# export TMP=/Volumnes/Work/pfkeb/HippoDraw-1.17.4
ki-mac03: root# export DYLD_LIBRARY_PATH=$WORK/qt/.libs:$WORK/lib/.libs
ki-mac03: root# make install

HippoDraw starts but no menu bar

If the HippoDraw applications starts but you can not select its windows and the HippoDraw, then you have started HippoDraw incorrectly. This can happen either running as a stand-a-lone application or as a Python extension module.

For the stand-a-lone application, one must first build a Mac application by typing ...

> make macapp

Mac OS X GUI applications must reside in a directory with a suffix .app. The above make command builds such a directory. The you can lanuch HippoDraw by double clicking on the directory, or issuing the command ...

> open hippodraw.app

If running HippoDraw as Python extension module than Python should be started as pythonw instead of python. For example, running the script displays.py in the examples directory like this...

> pythonw -i displays.py 

Building HippoDraw as Universal binary.

HippoDrraw can be built as Universl binary. In the configure step you add some options.to the compile and linker steps as described in Apple Developer documentation. However, they do not quite work. One needs to change the CFLAGS of CXXFLAGS because HippoDraw is compiled wih C++.

Also the configure script fails on Mac OS X 10.4 if the LDFLAGS is used Thus, what works or Mac OS X 10.4 was

CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386"\
configure --disable-dependency-tracking

For Mac OS 10.5 the following works...

CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386" \
LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386"\
/Users/pfkeb/hippodraw/configure --disable-dependency-tracking

--disable-dependedncy-tracking is needed as desribed by Apple because the compiler can not create the dependency files when commpiling for mulitple architectures. Thus building with universal binaries is not recommended for a developer's environment.

The above addition to he configure options insures that the code is compiled for both Intel i386 and power PC architectures. However, the builting of Universal libraries will be broken. To fix it, one need to patch the generated libtool script in the build directory. Apply the patch from the file libtool.patch located in the top level source directory like this

patch < libtool.patch

HippoDraw built as Universal binary will not link unless the libraries it depends on are also built as Universal binaries. The following sections should help in accommplishing that task.

Building Qt 3 as Universal binary

Qt uses qmake utility to build its Makefiles. qmake is controlled by configuration files in the mkspecs directory with one subdirectory for each OS compiler combination that is supported. Thus the file

qt-mac-free-3.3.8/mkspecs/macx-g++/qmake.conf

needs to be modified to include he compiler and linker options to build universal binaries. The file qt.patch is provided in the hippodraw top level source directory to make the change. One can use this file like this

> cd qt-mac-free-3.3.8/mkspecs/macx-g++
> patch < qt.patch

For Qt 4, use the options to the configure command as shown in Installing Qt4

Building Boost as Universal binary

Since Boost uses bjam instead of make, it's not obvious how to build it for universal binaries. However, the following patch was found by another project that uses Boost.

$ cd boost_1_33_1
$ patch -p0 <<EOF
--- tools/build/v1/darwin-tools.jam.orig        2006-08-07 11:52:23.000000000 +\0200
+++ tools/build/v1/darwin-tools.jam     2006-08-07 11:40:26.000000000 +0200
@@ -104,6 +105,8 @@
 {
     flags darwin C++FLAGS : -fcoalesce-templates ;
 }
+flags darwin CFLAGS : -arch i386 -arch ppc ;
+flags darwin LINKFLAGS : -arch i386 -arch ppc ;
 flags darwin LINKFLAGS <runtime-link>static : -static-libgcc ;
 flags darwin CFLAGS <debug-symbols>on : -g ;
 flags darwin LINKFLAGS <debug-symbols>on : -g ;
EOF

Note this patch adds two lines to the specified file.. After making this patch one can procced as in Installing Boost on Mac OS X.

Building Minuit Universal binary

For the Minuit library, the compile and linker steps as described in Apple Developer documentation. work to compile to Universal binaries, however, the linking step doesn't work apparently due to bug in libtool.

To compile Minuit to Universal binaries first issue the configure command like this

./configure CXXFLAGS="-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
-disable-dependency-tracking LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk \
-arch i386 -arch ppc"
Then edit the generated libtool script on the line containing archive-cmds = to look like this snipet...

# Commands used to build and install a shared archive.
archive_cmds="\$CC -dynamiclib -arch i386 -arch ppc -single_module \

Note there are two lines in the libtool script that have this variable. The one to edit is the the one with -single_module following -dynamiclib like shown above.


Generated for HippoDraw by doxygen