使用php -f调用测试的php文件,现实错误如下:
php: symbol lookup error: /usr/lib/php5/20060613+lfs/resdata.so: undefined symbol: php_pcre_compile
实际使用到的函数式pcre库中的pcre_compile,为什么这边提示是php_pcre_compile呢?undefined symbol又是指什么?
请不吝赐教!php扩展cpcre
php: symbol lookup error: /usr/lib/php5/20060613+lfs/resdata.so: undefined symbol: php_pcre_compile
实际使用到的函数式pcre库中的pcre_compile,为什么这边提示是php_pcre_compile呢?undefined symbol又是指什么?
请不吝赐教!php扩展cpcre
{
char *data;
unsigned int data_len;
char buf[256];
unsigned int buf_len = sizeof(buf); memset(buf, 0, buf_len);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE)
{
return;
}
pcre_test(data, buf, buf_len);
if( buf_len == 0)
return; RETURN_STRING(buf, 1);
}
#include "pcre.h"int pcre_test(char *pattern, char *buf, unsigned int buf_len)
{
pcre *re;
const char *error;
int erroffset; if(strlen(pattern) < 1)
{
snprintf(buf, buf_len-1, "Pattern is NULL.\n");
return 1;
} re = aapcre_compile(pattern, PCRE_UNGREEDY|PCRE_CASELESS, &error, &erroffset, NULL);
if (re == NULL)
{
snprintf(buf, buf_len-1, "Pattern failed at offset %d: %s.\n", erroffset, error);
return 1;
}
snprintf(buf, buf_len-1, "PCRE SUCCEED.");
free(re); return 0;
}
#include "ext/pcre/php_pcre.h"
PHP_METHOD(MyExt, pcre_compile_test) {
pcre *re;
char *pattern, *error ;
int pattern_len, erroffset;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&pattern, &pattern_len) == FAILURE) {
return;
}
re = pcre_compile(pattern,PCRE_UNGREEDY|PCRE_CASELESS, &error, &erroffset,NULL);
if (re == NULL) {
php_printf("PCRE compilation failed at offset %d: %s\n", erroffset, error);
RETURN_FALSE;
}
RETURN_TRUE;
}