Kris
Kris

Reputation: 8868

Loading GTK2 in PHP fails

I already did the following:

Installed PHP 5.3.3

Installed GTK 2.0.1

Installed the latest version of php-gtk from svn

All dependencies are resolved and installed.

I edited php.ini to load the GTk library in extension lib of PHP, as extension=php_gtk2.so and saved it.

If I check with php -m I'm finding one error like Unable to Load Dynamic Library ../../php_gtk2.so I'm assuming it may be because php_gtk2.so is a static library.

Then how can I load it.? Any idea where I made mistake?

I'm running on CentOS 6.0 Server,PHP 5.3.3,GTK 2.0.1

edit:

The exact problem is given below:

    [root@srv-vg phpapps]# php -m
    PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/lib/php/modules/php_gtk2.so' - 
/usr/lib/php/modules/php_gtk2.so: 
undefined symbol: php_cairo_get_context_ce in Unknown on line 0
    [PHP Modules]
    apc
    bz2
    calendar
    Core
    ctype
    curl
    date
    dom
    ereg
    exif
    fileinfo
    filter
    ftp
    gd
    gettext
    gmp
    hash
    iconv
    json
    ldap
    libxml
    memcache
    mysql
    mysqli
    odbc
    openssl
    pcntl
    pcre
    PDO
    pdo_mysql
    PDO_ODBC
    pdo_pgsql
    pdo_sqlite
    pgsql
    Phar
    readline
    Reflection
    session
    shmop
    SimpleXML
    soap
    sockets
    SPL
    sqlite3
    standard
    tokenizer
    wddx
    xml
    xmlreader
    xmlrpc
    xmlwriter
    xsl
    zip
    zlib

    [Zend Modules]

As hakre said, i tried loading cairo extension by adding the cairo.ini file. But now its also showing some error like this

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/cairo.so' - /usr/lib/php/modules/cairo.so: undefined symbol: cairo_ce_cairosubsurface in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/php_gtk2.so' - /usr/lib/php/modules/php_gtk2.so: undefined symbol: php_cairo_get_context_ce in Unknown on line 0
[PHP Modules]

edit2:

When i was installing cairo, there was a bug in cairo_surface.c and i cleared it as some one in the forums told to do how. I could install cairo successfully. But now, what about this!!

Upvotes: 4

Views: 1058

Answers (2)

Krishnadas PC
Krishnadas PC

Reputation: 6519

I have faced the same issue in ubuntu. What I have done to fix it was

  1. Changed the permission of the files php_gtk2.so, cairo.so in the directory /usr/lib/php5/20121212 to 644 . Earlier it was 777. The last number in the path may be different for other systems which I don't know.
  2. Updated the file sudo gedit /etc/php5/cli/php.ini Added the entry for these two modules in the section named Dynamic Extensions

    extension= /usr/lib/php5/20121212/cairo.so extension= /usr/lib/php5/20121212/php_gtk2.so

Please note the order, cairo.so must be the first one. Earlier php_gtk2.so was the first one which caused the error I believe.

  1. Finally managed to run the demos from the directory php-gtk-src from terminal using the command $ php demos/phpgtk2-demo.php

Hope it helps :)

Upvotes: 0

hakre
hakre

Reputation: 197692

So you installed from SVN. But something with the compiled binary has a problem to find the symbol php_cairo_get_context_ce.

Your module list shows that you do not have the cairo extension installed.

Install it and load it before php-gtk.

Upvotes: 1

Related Questions