cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

PHP Warning: PHP Startup: Unable to load dynamic library

Former Member
23,005

Hello,

I'm been trying to get PHP working with the sqlanywhere.so module and I get the following message. PHP Warning: PHP Startup: Unable to load dynamic library

PHP 5.2.17
Mac: O/S X : 10.6.6
Server version: Apache/2.2.15 (Unix)
Zend Server:

Sybase Version 7.0

In phpInfo(), it shows that my sqlanywhere.so extension is in the proper extension_dir, and the php.ini file shows that the extension is suppost to be loaded.

I've downloaded the latest module threaded version from the sybase website (ver 5.3.5) threaded and still doesn't work. In addition I've also tried to manually compile the extension and paste into my extension_dir, but get the same error.

Also my LD_LIBRARY_PATH is set in my env and does point to the library files, so when i run say ./dbsrv12 it works.

Please help this is very frustrating

View Entire Topic
Former Member

You say you are using Mac OS X 10.6.6 and that you downloaded a compiled version of the PHP driver from the Sybase website. As far as I know, we do not distribute a compiled version for Mac OS X. You would need to compile it yourself (I see you've done that, so, okay). Also, the library should likely have a .dylib extension on Mac OS X (though I suppose it's possible we're generating .so)

You say you have your LD_LIBRARY_PATH set in your environment. First, this should be called DYLD_LIBRARY_PATH on Mac OS X. I assume this is in a terminal? Do you know for sure that it is set properly for your Apache process? Usually if Apache is started as a service (or daemon), most operating systems will clear out the environment first to prevent variables accidentally getting included.

You can get the environment for your apache process (assuming the executable is called httpd) with the following command (as root):

# ps ewwxa | grep httpd | grep -v grep

You should see output similar to:

26295   ??  Ss     0:00.28 /usr/sbin/httpd -D FOREGROUND PATH=/usr/bin:/bin:/usr/sbin:/sbin
26297   ??  S      0:00.00 /usr/sbin/httpd -D FOREGROUND PATH=/usr/bin:/bin:/usr/sbin:/sbin

In this example you can see that the environment was reset.

Have a look at these points. If you find that the problem is with the Apache environment, it shouldn't be too difficult to figure out how to push the correct environment variables into the Apache process.

Former Member
0 Likes

using PHPINFO under Environment it shows: DYLD_LIBRARY_PATH=/usr/local/zend/apache2/lib:/Applications/SQLAnywhere12/System/lib32. Is this correct?

I also ran the code you provided: but had to add an underscore between FOREGROUND and PATH, otherwise it just brings up the list of commands for httpd ie: /usr/sbin/httpd -D FOREGROUND_PATH=/usr/bin:/bin:/usr/sbin:/sbin

Once I ran that command how do I check to see if the apache environment getting these values? I didn't see FOREGROUND_PATH in the environment section of PHPINFO after I restarted apache, but I'm unsure if its suppose to be there.

Former Member
0 Likes

Only the first line was the command. The second two lines are the output I saw on the mac 10.6 box I have at my disposal.

How are you getting the phpinfo you describe? The DYLD_LIBRARY_PATH seems reasonable enough. But is it just coming from your terminal, or is it actually set within your apache process?

If the PHP driver loaded properly, there should be a section in phpinfo referring to SQL Anywhere. If that section is there, then your immediate problem has nothing to do with the environment settings.

You need to be sure that the library that you have installed in PHP was compiled for your platform. That not only means that it has to be built for Mac OS X (your original post implied that you were using the Linux driver which is not compatible), but also that the pointer size matches. If you run file php with your php binary as well as file sqlanywhere.dylib with the sqlanywhere driver you're using you should see the same output (apart from the file name). This also needs to match your apache binary.