Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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

asked 21 Mar '11, 14:31

livinlifeloud's gravatar image

livinlifeloud
61116
accept rate: 0%

edited 21 Mar '11, 14:42

Graeme%20Perrow's gravatar image

Graeme Perrow
9.6k379124

When you say "Sybase Version 7.0", what do you mean? I'm pretty sure we didn't have a PHP module in SQL Anywhere Studio 7.0, and you do mention dbsrv12, which implies that you're using SA version 12.

(21 Mar '11, 14:44) Graeme Perrow

Sorry for the confusion, at work we have a Sybase database version 7, and yes I am using SA version 12

(21 Mar '11, 14:47) livinlifeloud
Replies hidden

This is still confusing me - what does "we have a Sybase database version 7" mean? Does this mean that your database was created with version 7 or does this mean that your company owns a license for version 7 (but that you have downloaded a dev-ed version of SA 12)? Please explain.

Note we ask because dbsrv12 cannot start a version 7 database.

(21 Mar '11, 15:30) Mark Culp

Our database was created with version 7 and I have downloaded a dev-ed of SA 12.

I would still like to be able to install the PHP module however, because they are currently migrating over to the latest database version of sybase.

(21 Mar '11, 15:39) livinlifeloud

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....

permanent link

answered 23 Mar '11, 14:44

livinlifeloud's gravatar image

livinlifeloud
61116
accept rate: 0%

Glad to see you finally got it working. Hopefully using the product is a little easier than integrating it into your system.

(23 Mar '11, 16:10) Phil Mitchell

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.

permanent link

answered 23 Mar '11, 08:21

Phil%20Mitchell's gravatar image

Phil Mitchell
1.9k1831
accept rate: 27%

Ok good to know.. the documentation says to always download the latest version, but I guess that doesn't matter for the mac and I need to use the dylib files.

(23 Mar '11, 08:40) livinlifeloud
Replies hidden
1

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.

(23 Mar '11, 08:46) Phil Mitchell

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.

permanent link

answered 23 Mar '11, 08:44

Phil%20Mitchell's gravatar image

Phil Mitchell
1.9k1831
accept rate: 27%

I tried what you mentioned and am still getting the error PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/zend/lib/php_extensions/sqlanywhere.so' - (null) in Unknown on line 0

Does it matter the I'm using Zend Server?

(23 Mar '11, 09:14) livinlifeloud
Replies hidden

When do you get the error message? Is it when you run /usr/bin/php --info? Or is it when you start your Zend server?

(23 Mar '11, 09:24) Phil Mitchell

right after i follow what you wrote if i run 'make test', or after i restart apache then run "php -m", also when zend server starts and I check the log files.. it shows up there as well

(23 Mar '11, 09:35) livinlifeloud
Replies hidden

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

(23 Mar '11, 10:04) Phil Mitchell

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 :(

(23 Mar '11, 10:29) livinlifeloud
Replies hidden

Hmmm...then I'm stumped.

(23 Mar '11, 10:33) Phil Mitchell

very discouraging. if the expert is stumped what chance do i have..

(23 Mar '11, 11:56) livinlifeloud
Replies hidden

Can you try to make it work with regular PHP to rule out any issues specific to Zend server?

(23 Mar '11, 12:01) Phil Mitchell

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?

(23 Mar '11, 13:59) livinlifeloud
Replies hidden

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.

(23 Mar '11, 15:33) Phil Mitchell
showing 5 of 10 show all flat view

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.

permanent link

answered 22 Mar '11, 09:05

Phil%20Mitchell's gravatar image

Phil Mitchell
1.9k1831
accept rate: 27%

edited 22 Mar '11, 19:06

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.

(22 Mar '11, 11:04) livinlifeloud

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.

(22 Mar '11, 19:05) Phil Mitchell
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×438
×70
×31

question asked: 21 Mar '11, 14:31

question was seen: 19,431 times

last updated: 23 Mar '11, 16:10