on 2011 Mar 21 2:31 PM
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
OMG after weeks finally figured it out! PHP is not build in 64 bit, and I was trying to load a 64 bit module to a 32 bit application and of course it won't work. I checked the bit of the extension by using the file command and got this
$ file /usr/local/zend/lib/php_extensions/sqlanywhere.so /usr/local/zend/lib/php_extensions/sqlanywhere.so: Mach-O 64-bit bundle x86_64
Then I used the below way to compile to make 32 bit module instead and ran the file command again and got.
$ file /usr/local/zend/lib/php_extensions/sqlanywhere.so /usr/local/zend/lib/php_extensions/sqlanywhere.so: Mach-O bundle i386
USE The below to complie as 32 bit:
phpize CFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -g -Os' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -g -Os'
./configure --disable-dependancy-tracking --disable-shared -enable-static
I was stumped, but now I see....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to build and load the SQL Anywhere PHP driver on a Mac OS X 10.6.0 machine with the following commands:
curl http://download.sybase.com/ianywhere/php/2.0.10/sasql_php.zip -o sasql_php.zip
unzip -a sasql_php.zip
cd sqlanywhere
/usr/bin/phpize .
./configure
make
su
make install
echo "extension=sqlanywhere.so" >> /etc/php.ini
exit
/usr/bin/php --info | grep -i sqlanywhere
You will have to substitute /usr/bin
with the location of your PHP installation (for both php
and phpize
). Also use the correct location of php.ini
as can be found with /usr/bin/php --info | grep php.ini
.
The last line should produce output similar to:
sqlanywhere
SQLAnywhere support => enabled
PHP SQLAnywhere driver version => 2.0.10.0
SQLAnywhere client version => 12.0.1.3152
sqlanywhere.allow_persistent => On => On
sqlanywhere.auto_commit => On => On
sqlanywhere.max_connections => Unlimited => Unlimited
sqlanywhere.max_persistent_connections => Unlimited => Unlimited
sqlanywhere.verbose_errors => On => On
If your DYLD_LIBRARY_PATH
is not set correctly you will see the following value for SQLAnywhere client version (instead of 12.0.1.3152
😞
SQLAnywhere client version => The SQLAnywhere client libraries could not be loaded. Please ensure that libdbcapi.so can be found in your LD_LIBRARY_PATH environment variable.
Admittedly, the specific details in that error message are incorrect for Mac OS X, but the idea is correct.
Once you have this working, it should be fairly easy to get it to work in Apache.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is the file in /usr/local/zend/lib/php_extensions/sqlanywhere.so
the same one you just built? Or is it an older one?
I've never used Zend. It may have PHP compiled in a different way (threaded vs non-threaded, or some other difference). PHP is exceptionally picky about differences in compiling. Make sure when you use phpize
that you're using the one from the Zend installation (if there is one), otherwise there may be a difference.
You may also want to look at this forum post: http://forums.zend.com/viewtopic.php?f=59&t=2365&p=9981
Yes it is the sqlanywhere.so that is being built, I validated by removing the file and watching to see if another gets copied into that ext directory once I run the above install, and it does. The phpize bin is the one included in the zend install /usr/local/Zend/bin, and when I run phpize i include the full path.
I checked the link and added the ARCHPREFERENCE to env.. still same result 😞
I tried to install the latest zend server 5.3, and this error is the same but slightly different
Warning: PHP Startup: Unable to load dynamic library '/sqlanywhere/modules/sqlanywhere.so' - dlopen(/sqlanywhere/modules/sqlanywhere.so, 9): no suitable image found.
Did find: /sqlanywhere/modules/sqlanywhere.so: mach-o, but wrong architecture in Unknown on line 0
any idea on this?
It still appears that your Zend server is a different architecture than the sqlanywhere.so module you've built. The output of the following two commands should be (almost) identical:
file /usr/local/zend/lib/php_extensions/sqlanywhere.so
file php
...make sure you give the full path to the PHP binary. If they differ, then that should indicate your problem.
When you say you downloaded the binary for version 5.3.5, it's important to note that the version you download must match the PHP version you have (this is why there are so many versions posted). You indicated that you have PHP version 5.2.17, so you should download the version of our library compiled for PHP version 5.2.17...which I see we don't actually have posted at the moment for some reason (we do have it available if needed).
Anyway, since you're on a Mac, the posted binaries won't work. However, I feel that it's an important point to make.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, sorry. The word "version" here means a couple of things. The "version" that the doc refers to relates specifically to our code. In that respect, all of the ones that are posted on the web site are always the latest version. The "PHP version" column in the table refers to the version of PHP, which is independent of our code.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
User | Count |
---|---|
75 | |
9 | |
9 | |
8 | |
8 | |
7 | |
7 | |
6 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.