How to compile Gtk-Server on MacOSX

Requirements

To compile Gtk-Server on MacOSX you will need:

Step 1 - Installing the Gtk libraries

If you haven't already done you should install the gtk libraries and headers with: (NB: the following output appears only if you have already installer the gtk libraries and headers)

      $ sudo apt-get install gtk+2 gtk+2-dev
      Reading Package Lists... Done
      Building Dependency Tree... Done
      Sorry, gtk+2 is already the newest version.
      Sorry, gtk+2-dev is already the newest version.
      0 packages upgraded, 0 newly installed, 0 to remove and 22  not upgraded.
    

Step 2 - Compiling and installing the libffi package

Now you should uncompress the libffi source package with: (please correct the source package effective location)

      $ tar xvzf libffi-src.tar.gz 
      libffi-src/
      libffi-src/CVS/
      libffi-src/CVS/Root
      libffi-src/CVS/Repository
      libffi-src/CVS/Entries
      ..... more output here .....
      $ 
    

Now you should enter in the created directory and start the configure script with:

      $ cd libffi-src
      $ ./configure --with-target-subdir=.
      ..... lot of output here .....
      updating cache ./config.cache
      creating ./config.status
      creating include/Makefile
      creating testsuite/Makefile
      creating include/ffi.h
      creating Makefile
      creating fficonfig.h
      fficonfig.h unchanged
      Adding multilib support to Makefile in .
      with_multisubdir=
      $
    

And now you can issue make

      $ make
      ..... lot out output here .....
      $
    

And now you should make install as root

      $ sudo make install
    

Compiling and installing the Gtk-Server package

Uncompress the gtk-server source package: (please correct the sourcepackage location)

      $ tar xvzf gtk-server-2.0.12.tar.gz 
      ..... lots of output here .....
    

Now you should configure the gtk-server package with:

      $ cd gtk-server-2.0.12/
      $ ./configure --with-gtk2
      ..... lots of output here .....
      checking for strstr... yes
      configure: creating ./config.status
      config.status: creating Makefile
      config.status: creating config.h
      $
    

But remember: the FIFO protocol with gtk-server under MacOSX probably does not work and is in testing phase.

And now you can compile with:

      $ make
      gcc -Wall -pedantic -I/sw/include/gtk-2.0 -I/sw/lib/gtk-2.0/include -I/sw/include/atk-1.0 -I/sw/include/pango-1.0 -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include    -DHAVE_CONFIG_H -DLOCALCFG=\"/usr/local/etc/gtk-server.cfg\"   -c -o gtk-server.o gtk-server.c
      gcc -o gtk-server gtk-server.o  -lffi -L/sw/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -liconv  
      ld: warning multiple definitions of symbol _locale_charset
      /sw/lib/libiconv.dylib(localcharset.o) definition of _locale_charset
      /sw/lib/libintl.dylib(localcharset.lo) definition of _locale_charset
      ld: warning suggest use of -bind_at_load, as lazy binding may result in errors or different symbols being used
      symbol _locale_charset used from dynamic library /sw/lib/libiconv.dylib(localcharset.o) not from earlier dynamic library /sw/lib/libintl.1.dylib(localcharset.lo)
      strip gtk-server
      $
    
And now, if you want, you can:
      $ sudo make install
    

Step 3 - Post-Configuration

Now you should change your gtk-server.cfg file to reflect the MacOSX configuration. You should only change the library names (in the head of the configuration file) to reflect the library extension on MacOSX.

As esample my gtk-server.cfg file in MacOSX starts with:

       # Config file containing API calls used by the GTK-server.
       #
       # Do you want to use more GTK functions? Please consult the GTK documenation
       # at http://www.gtk.org/api/
       #---------------------------------------------------------------------------
       # Only when the gtk-server binary does not contain the GTK libs, this
       # setting must be changed.
       #
       # For Linux uncomment these:
       GTK_LIB_NAME = libgtk-x11-2.0.dylib
       GDK_LIB_NAME = libgdk-x11-2.0.dylib
       GLIB_LIB_NAME = libglib-2.0.dylib
       PIXBUF_LIB_NAME = libgdk_pixbuf_xlib.dylib
       #
    

Instead of:

       # Config file containing API calls used by the GTK-server.
       #
       # Do you want to use more GTK functions? Please consult the GTK documenation
       # at http://www.gtk.org/api/
       #---------------------------------------------------------------------------
       # Only when the gtk-server binary does not contain the GTK libs, this
       # setting must be changed.
       #
       # For Linux uncomment these:
       GTK_LIB_NAME = libgtk-x11-2.0.so
       GDK_LIB_NAME = libgdk-x11-2.0.so
       GLIB_LIB_NAME = libglib-2.0.so
       PIXBUF_LIB_NAME = libgdk_pixbuf_xlib.so
    

Concluding

I hope you have completed all the steps.

Now you should only put some environment variables to make gtk-server work correctly. As an esample you should run something similiar to this bash script before using gtk-server.

      # Gtk-server
      export GTK_SERVER_CONFIG=/Users/leonardo/gtk-server-2.0.12/gtk-server.cfg
      export PATH=$PATH:$HOME/gtk-server-2.0.12
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib