Object Oriented PHP-GTK2 - Compile PHP-GTK on Unixesque Systems Object Oriented PHP-GTK2 - Compile PHP-GTK on Unixesque Systems
it's me, bob. lol. Object Oriented PHP-GTK2 OOPS

Compile PHP-GTK on Unixesque Systems

How to compile PHP-GTK from the source code.

Topic: Compiling PHP-GTK2 (View All Tutorials)
Keywords: php gtk compile source unix linux freebsd solaris
Updated: A Long Time Ago, 2007/11/23 21:50

This document does not care about what distribution you use, these instructions will work on all shapes of Linux, FreeBSD, or Solaris. It is up to you to translate any line into the required line for your distribution. I will however tell you right now, if you are on Ubuntu and never done this before, you are missing pretty much every package you need.

Actually, I lied. This document does care what OS you use. I cannot help you with Compiling on Windows. This post here on Elizabeth's blog might help you out though.

Tested Systems:

  • KateOS 3.6
  • Ubuntu 7.10
  • FreeBSD 6.2
  • Solaris 10

Systems I plan to test:

Before you actually execute a command, check under the command example box for any distribution notes that might effect you.

#1 Rule: Use your distributions package management utilties as much as possible, only compile when you absolutely have to. With the popularity of certain distributions I will make notes about what packages you might need to install.

Distribution Note: Ubuntu

You do not need any special repositories, all required packages can be installed from the default ones that come setup in the distribution.

Distribution Note: FreeBSD

I have used ports to fill all dependencies except PHP, the version of PHP in ports was too old for my liking, so I compiled it myself from the official tarball.

Distribution Note: Solaris

I used the Blastwave repository for Solaris to fill and update all dependencies except for PHP5 itself, it was the only thing I manually compiled. I used the repository to fill PHP5's dependencies as well.

 

Requirements

To compile PHP-GTK you need several things:

  1. Autotools (automake, autoconf, etc...)
  2. Compile Tools (make, gcc, etc...)
  3. GTK+ 2.10 or newer, including headers.
  4. PHP 5.2 or newer, including headers.
  5. LibGlade, including headers.
  6. CVS

Nearly all distributions will already have your Autotools and the Compile Tools already installed and setup right off the Installation CD, so chances are you can ignore #1 and #2. Installing these is far beyond the scope of this document, but they can usually be installed with your distribution package manager making your life easy. Be sure to install the development packages too.

Distribution Note: Ubuntu

You are missing a lot of required packages, most of them are the development headers that you do not need unless compiling a GTK application (or PHP-GTK). You must install these packages before proceeding. Accept any and all dependencies it says are required for these as well.

php5-cli, php5-dev, php5-gd, libgtk2.0-dev, and libglade2-dev.

After accepting these packages and all their automatic dependnecies you should have installed a lot of packages packages, probably about 30MB worth of downloads. But after this,you are ready to compile stuff and can skip past the rest of this section.

Distribution Note: FreeBSD, Solaris

Be sure you have gmake, and all the GNU tools like Autoconf.

Distribution Note: FreeBSD

On the command type autoconf and hit tab. If none of the results are just autoconf but rather something like autoconf259 you will have to symlink it. The same goes for autoheader. If you failed at this, PHP-GTK's buildconf script will let you know.

ln -s /usr/local/bin/autoconf259 /usr/local/bin/autoconf
ln -s /usr/local/bin/autoheader259 /usr/local/bin/autoheader

Most modern distribution will have GTK+ 2.10 or newer installed, if you are using Gnome, XFCE, or any GTK applications then you have it. However you might not have the headers, and by that I mean development packages. You must have the development packages installed. If you compiled and installed GTK from source then you are done. If not scan your package manager, also install any Pango and ATK development packages if you see them.

Distribution Note: Solaris

You will need to install updated GTK2 and related packages from the Blastwave repository, which will install into /opt/csw so that it will not interfere with the GTK libraries that came with Solaris which are very old.

PHP 5.2 or newer. If your package manager will allow you to install this without installing Apache, then you are in fact a winner. Distributions that over-modularize will probably require you to install several packages such as `php5`, `php5-gd`, and `php5-cli`. Install those three at least, and also the development package, probably named something like `php5-dev`. You will have to compile your own PHP if the version your distribution provides is older than 5.2.0, or does not provide any at all.

Too many PHP-GTK applications depend on LibGlade, so you should install it because chances are you will eventually run into a program using it.

Glade and GTK 2.12

As of GTK 2.12 Glade has been depreciated in favour of the GtkBuilder class that is built into GTK. Please make note of this if you plan on developing applications.

Install CVS if you do not have it already, because that is how we are going to get the PHP-GTK source. The CVS repository usually has fixes that are not yet out. One such is a problem with if your package had a separate package for PHP-GD like I said above. There is a fix for this in PHP-GTK which was added after the most recent release, I will update this document the next PHP-GTK release to reflect that change and hereby eliminiating this step.

 

Getting PHP-GTK

You need the source to compile it, so run these CVS commands:

cvs -d :pserver:cvsread@cvs.php.net:/repository login
<hit enter when it asks for a password>
cvs -d :pserver:cvsread@cvs.php.net:/repository co php-gtk

It will do it's thing, and after you have a new php-gtk directory. Change into that new directory.

 

Compiling PHP-GTK

Run the command:

./buildconf
Distribution Note: Solaris

You need to export a MAKE variable set to "gmake" before running buildconf:

export MAKE=gmake
./buildconf

If this does not complete successfully then you are probably missing packages. A common error is 'unable to find phpize' and this means you did not install the PHP development package.

After Buildconf, run the command:

./configure
Distribution Note: FreeBSD

Your configure command needs to be a little different. Use this instead:

./configure CFLAGS="-lpthread"

Distribution Note: Solaris

If you used the Blastwave repository like I did to fill dependencies you must:

crle -l "/opt/csw/lib:/lib:/usr/lib"
./configure PKG_CONFIG_PATH="/opt/csw/lib/pkgconfig"

The same rules apply here, if it fails to complete successfully you probably forgot to install some packages or their development counterpart packages. Scroll back up through the output to make sure it found LibGlade.

checking for libglade support... yes
checking for libglade-2.0 >= 2.4.0... yes

You can still use PHP-GTK without this but when you download a program and it says 'unknown class: GladeXML' that is because you did not listen to me when I said to install LibGlade.

So Configure finally completed successfully? Next, run the command:

make
Distribution Note: FreeBSD, Solaris

You should use `gmake` every time I tell you to use `make`.

Wait for it... wait for it... did it complete successfully? It really should have, by now you should have fixed all the dependency problems. When that finishes (successfully) then you can run the command (as root):

make install

When that finishes, PHP-GTK is now installed. But hang on, you are not done yet.

 

Configure PHP and PHP-GTK

With PHP and PHP-GTK installed, you now need to configure PHP to work with GTK.

Continue to the configuration document.

Was this document helpful? I appreciate your feedback.
What are the rules about reusing this code?


i can has web two point ooh // copyright © 2007-2008 bob majdak jr
[ xhtml css | firefox ie7 opera ]