Weird PHP Error after FreeBSD port upgrade (PHP Warning: PHP Startup: Unable to load dynamic library)

Today I upgraded the port on my FreeBSD box using portmaster tools:

portmaster -Dai

After that, I found that the PHP gave the following weird error:

php -v

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/memcached.so' - /usr/local/lib/php/20060613/memcached.so: Undefined symbol " php_session_create_id" in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/mysql.so' - Cannot open "/usr/local/lib/php/20060613/mysql.so" in Unknown on line 0

PHP 5.2.12 with Suhosin-Patch 0.9.7 (cli) (built: Apr  6 2010 15:50:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

In order to solve this problem, you will need to rebuild the port. In my situation, I need to clean up, uninstall, rebuild and install the affected ports:

Memcached: /usr/ports/databases/pecl-memcached

MySQL: /usr/ports/databases/php5-mysql

——————————————————————————————
Update on 2010.04.13:
Your situation may be different from mine. The tricky part is to rebuild the port at the right location. For example, if your PHP complains about pdo.so, you can rebuild the port at the affected location:

/usr/ports/database/php5-pdo

If you are not sure where does the port locate, you can search it on Google or find it with the following command:

find /usr/ports/ -name "*pdo*"

——————————————————————————————

In each affected port, run the following commands:

make clean
make deinstall
make
make install && sync
make clean

After that, restart the PHP by restarting Apache:

sudo apachectl restart

and run the php command again:

php -v

The error should be gone:

PHP 5.2.12 with Suhosin-Patch 0.9.7 (cli) (built: Apr  6 2010 15:50:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Our sponsors:

5 Replies to “Weird PHP Error after FreeBSD port upgrade (PHP Warning: PHP Startup: Unable to load dynamic library)”

  1. Brent Kochel

    hey,I find out that your blog is extremely beneficial and useful and we were curious if there is really a possibility of acquiring More article content like this on your weblog. If you willing to support us out, we can be willing to compensate you… Yours, Brent Kochel

    Reply
  2. Odell Bombaci

    You wouldn’t believe it but I’ve wasted all day digging for some articles about this. You’re a lifesaver, it was an excellent read and has helped me out to no end. Cheers,

    Reply
  3. Dimitar Haralanov

    I am having the same problem with pecl-memcached.

    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/20090626/memcached.so’ – /usr/local/lib/php/20090626/memcached.so: Undefined symbol “php_session_create_id” in Unknown on line 0

    I tried the steps you suggested but still nothing works. I still get the same error. Wondering what to do next.

    Reply
    • Derrick Post author

      Hi Dimitar,

      Make sure that you rebuild the port at: /usr/ports/databases/pecl-memcached
      (not /usr/ports/databases/pecl-memcache, there is no ‘d’ at the end)

      –Derrick

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *