Can't get php5 to build on machines that have php4 or have had php4

Bjoern Koenig bkoenig at cs.tu-berlin.de
Mon May 23 05:48:06 PDT 2005


Edwin L. Culp wrote:

> I have php5 running with no problems on machines that I installed it 
> initially but I've not been able to compile php5 on any machine that has 
> or has had ( deleted with pkg_delete php4*).  I can't find the reason 
> for the error that I get in all cases.
> 
> ext/standard/dns.lo(.text+0x131f): In function `zif_dns_get_record':
> : undefined reference to `res_ninit'
> ext/standard/dns.lo(.text+0x1365): In function `zif_dns_get_record':
> : undefined reference to `res_nmkquery'
> ext/standard/dns.lo(.text+0x138d): In function `zif_dns_get_record':
> : undefined reference to `res_nsend'
> ext/standard/dns.lo(.text+0x148f): In function `zif_dns_get_record':
> : undefined reference to `res_nclose'
> *** Error code 1
> 
> Stop in /usr/ports/lang/php5/work/php-5.0.4.
> *** Error code 1

Could it be that you have built a world with option WITH_BIND_LIBS=yes 
or installed dns stuff from ports?

I had also problems with PHP and undefined references to these functions 
because FreeBSD does not install the header files which belong to the 
libraries if you use WITH_BIND_LIBS=yes, i.e. the definitions

   #define res_ninit       __res_ninit
   #define res_nmkquery    __res_nmkquery
   #define res_nsend       __res_nsend
   #define res_nclose      __res_nclose

and others are missing. You can solve the problem if you prepend "__" to 
these functions in the PHP source code. I attached a patch to this mail. 
Put it into /usr/ports/lang/php5/files, 'make clean' and install PHP again.

The PHP project don't feel responsible for their non-working and 
ignorant configure script.

Regards Björn
-------------- next part --------------
--- ext/standard/dns.c.bak	Mon May 23 14:32:16 2005
+++ ext/standard/dns.c	Mon May 23 14:33:18 2005
@@ -254,7 +254,7 @@
 			WRONG_PARAM_COUNT;
 	}
 
-	i = res_search(Z_STRVAL_PP(arg1), C_IN, type, ans, sizeof(ans));
+	i = __res_search(Z_STRVAL_PP(arg1), C_IN, type, ans, sizeof(ans));
 
 	if (i < 0) {
 		RETURN_FALSE;
@@ -627,17 +627,17 @@
 				break;
 		}
 		if (type_to_fetch) {
-			res_ninit(&res);
+			__res_ninit(&res);
 			res.retrans = 5;
 			res.options &= ~RES_DEFNAMES;
 		
-			n = res_nmkquery(&res, QUERY, Z_STRVAL_P(host), C_IN, type_to_fetch, NULL, 0, NULL, buf.qb2, sizeof buf);
+			n = __res_nmkquery(&res, QUERY, Z_STRVAL_P(host), C_IN, type_to_fetch, NULL, 0, NULL, buf.qb2, sizeof buf);
 			if (n<0) {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "res_nmkquery() failed");
 				zval_dtor(return_value);
 				RETURN_FALSE;
 			}
-			n = res_nsend(&res, buf.qb2, n, answer.qb2, sizeof answer);
+			n = __res_nsend(&res, buf.qb2, n, answer.qb2, sizeof answer);
 			if (n<0) {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "res_nsend() failed");
 				zval_dtor(return_value);
@@ -673,7 +673,7 @@
 					add_next_index_zval(return_value, retval);
 				}
 			}
-			res_nclose(&res);
+			__res_nclose(&res);
 		}
 	}
 
@@ -741,7 +741,7 @@
 	array_init(mx_list);
 
 	/* Go! */
-	i = res_search(Z_STRVAL_P(host), C_IN, T_MX, (u_char *)&ans, sizeof(ans));
+	i = __res_search(Z_STRVAL_P(host), C_IN, T_MX, (u_char *)&ans, sizeof(ans));
 	if (i < 0) {
 		RETURN_FALSE;
 	}


More information about the freebsd-ports mailing list