[Gtk]MathView under MacOSX

From: Luca Padovani <lpadovan_at_cs.unibo.it>
Date: Fri Aug 05 2005 - 20:07:39 CEST

Hello everyone,

after some struggle I managed to have GtkMathView compile and run under
MacOSX (see CVS HEAD). Well, to be precise only the SVG backend compiles
and runs, as I didn't bother to install GTK+. And, to tell the whole
truth, I had to use some packages from fink, but just the bare minimum:

* libxml2 >= 2.6.7
* GLIB >= 2.2.1
* autotools

There are a few major problems remaining, for which I'd like to have a
better solution:

getopt
======

The mathmlviewer and mathmlsvg binaries parse command line options using
getopt_long. This function is normally provided, under Linux, by the
standard C library. There is no need to link other libraries, all one
has to do is to #include <getopt.h>.

Under MacOSX, getopt.h is not provided. However there is a declaration
for getopt (not getopt_long!) in unistd.h. The problem about getopt is
that it does not recognize the long format of command line options (such
as --version).

Fink provides a package called gnugetopt which provides getopt_long,
however
a) as it is installed under /sw/... and has no pkgconfig file, I
couldn't make autoconf/configure find it
b) even if you manage to find where the include file is, the C++
compiler stops with an error as in gnugetopt/getopt.h there is a fake
prototype declaration for the simple getopt which conflicts with the one
provided in unistd.h

Currently I hacked gtkmathview's sources so that if getopt_long is not
available, getopt is used instead. Any suggestion as to portably
checking whether getopt_long is available and how to link it correctly
are appreciated.

SmartPtr.hh
===========

This class implements the smart pointers in gtkmathview. It appears to
use a valid C++ construct which is not supported by GCC 3.3 under
MacOSX, whereas under Linux it is supported by GCC 3.3.6 and later
versions. By moving two friend functions outside of the class body, it
works under MacOSX as well, but this makes me feel very uncomfortable:
the problem is (was) in GCC, and I hate when I have to hack the code to
work around other software's bugs. In CVS I have committed two files

  src/common/SmartPtr.hh (working under MacOSX, hacked)
  src/common/SmartPtr.hh.clean (working under Linux, clean)

I couldn't imagine any easy way to have one using the first or the
second, depending on which compiler is used, and I'm (almost) ready to
use the hacked version if it doesn't show problems.

Again, if anyone has any thought, please let me know.

Traits
======

GCC 3.3 under MacOSX does not provide

        char_traits<wchar_t>::copy
        char_traits<wchar_t>::move
        char_traits<wchar_t>::assign

As explicit template class instantiation has no effect in that GCC (and
explicit template class member instantiation is broken), the only way to
force the compiler to link the explicitly provided versions of those
methods is to define three (otherwise unused) static variables
containing the address of the three methods above. This evil thing can
be admired in

        src/common/CharTraits.icc

(beware, not for the faint-hearted).

Fortunately, systems with sane versions of GCC won't compile this in, as
configure makes some checks.

======

Apart from the problems above, I'm very happy that gtkmathview has
landed on MacOSX (the SVG produced by mathmlsvg can be directly seen
with the Adobe SVG plugin!). I'm looking forward to seeing it integrated
with AbiWord, just as it happened a few days ago with the Win32
platform, thanks to the work of Marc Maurer.

Cheers,
--luca

Received on Fri Aug 5 20:14:47 2005

This archive was generated by hypermail 2.1.8 : Fri Aug 05 2005 - 20:14:47 CEST