Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Compiling PHP with MySQL

645864Feb 10 2011 — edited Feb 16 2011
Hello all,

I am having trouble compiling php 5.2 (also tried 5.3). This is my configure line:
=======
./configure with-apxs2=/usr/local/apache2/bin/apxs with-mysql=/opt/mysql/mysql
=======

When I run "make", I get the following error:
=======
Undefined first referenced
symbol in file
mysql_set_character_set ext/mysql/php_mysql.o
ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `sapi/cli/php'
=======

Here are my machine details:
=======
@[machine-name]-/usr/local/php5.2 # uname -a
SunOS [machine-name] 5.10 Generic_138889-03 i86pc i386 i86pc Solaris

@[machine-name]-/usr/local/php5.2 # isainfo -kv
64-bit amd64 kernel modules
=======

PHP compiles fine when I do it without MySQL. Any assistance is greatly appreciated.

Please let me know if you need additional information.

Thank you.
-Ryan

Comments

645864
As an additional note, the MySQL server was installed at:
/opt/mysql/mysql
645864
There is an old version of MySQL installed on the machine in addtion to /opt/mysql/mysql. Can this be the problem?
Hi,

first of all please mind that PHP 5.2 is out of support by the PHP developers on php.net. To receive bug fixes petc. you should use PHP 5.3.

Secondly it is worth noticing that there are three function libraries (extensions) which allow accessing the MySQL database. One is the classic "mysql" extension, one is called mysqli, with "i" as in improved, and a driver for the PDO database abstraction - PDO_mysql. You are only activating one of these, in most situations you want all three of them gor maximum application compatibility.

Now with PHP 5.3 PHP bundles an implementation complete of the MySQL Client functionality. So linking against a local installation is not needed. This implementation is called mysqlnd - MySQL native driver.

To build w/ mysqlnd and all three function libraries use a configure line like this:

./configure with-apxs2=/usr/local/apache2/bin/apxs with-mysql=mysqlnd with-mysqli=mysqlnd with-pdo-mysql=mysqlnd

If you have a strong reason for 5.2 or using libmysql I'd need more information, like which version of mysql was installed. Was it self-compiled or binaries from mysql.com etc. But I hope the above is fine.

johannes
645864
Thank you for your time Johannes.

I put PHP 5.3 on the machine, and tried the configure line you described:
./configure with-apxs2=/usr/local/apache22/bin/apxs with-mysql=mysqlnd with-mysqli=mysqlnd with-pdo-mysql=mysqlnd

I still get the same type of error:

Undefined first referenced
symbol in file
mysql_list_dbs ext/mysql/.libs/php_mysql.o
mysql_fetch_row ext/mysql/.libs/php_mysql.o
mysql_fetch_field ext/mysql/.libs/php_mysql.o
[...many more "undefined symbol"s for mysql]

ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `sapi/cli/php'


What does "undefined symbol" mean? Any ideas? Thank you.
Did you run "make clean" in between? This looks like some results from the previous build attempt are still in the tree.
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 16 2011
Added on Feb 10 2011
5 comments
585 views