Wednesday, January 4, 2012

phpize error: unknown type name 'pval'

got this error ? suddenly unknown pval type ? because upgrading from php 5.3 to php 5.4 ?, sucks right ?

yeah, pval has been changed to zval, so if we find any source that use pval type, we need to find the newer source that has been  updated to zval, if we unlucky to find one, edit the source by our self.

I got this problem when I tried to do 'pecl install stats' under php 5.4, the error was beginning with :

/var/tmp/stats/statistics.c:165:2: error: unknown type name 'pval'

well, then manually replace all pval with zval under statistics.c file (total 5 replacement, using %s vi command), but with one trick, since PECL will always reload from the source and delete any temporary local file, we have to make our updated file unwriteable, by issuing chattr +ui /var/tmp/stats/statistics.c., and the trick to get that statistic.c at the first time, press ctrl break on the first stage of pecl install when it decompressing the source, then update and lock the file with above trick.


RJCookeSE said...

This is a great tip. After I execute pecl install stats, though, there is no copy of statistics.c that I can find. It's compiling from /tmp/pear/temp/stats but after the install fails, the stats folder is no longer there. Is there a way to first get a local copy of the source?

RJCookeSE said...

Hey, figured it all out. Thanks again for this post.

arpol said...

hi rj, great to hear that you can figure it out, I updated the tips above with how I got the statistic.c file under tmp file at the first time.

Alexander Kachkaev said...

I had the same problem with php 5.4. Type pval is unregistered in this version, so the package does not compile when I install it using a standard way:

sudo pecl install stats – does not work

It is impossible to change the source code of the downloaded tgz in MacOS X like described above as it always goes into a new temporary directory. Because of that I had to update the package and install it from local tgz. Here is how I did it:

1) I downloaded the package: pecl download stats
2) Then I unpacked it into a new directory, replaced all occurrences of pval in statistics.c with zval.
3) Then I updated md5 checksum in package.xml (the checksum is calculated using “openssl md5 statistics.c”
4) Compressed everything back “cd new-temporary-directory-with-package-contents | tar -zcf stats-1.0.2-php54.tgz *”

After that, it was possible to install a modified version of the package the following way:

sudo pecl install -O stats-1.0.2-php54.tgz

Finally, I manually added “” to my php.ini file and it started working! To check that you can run

php -r "echo stats_standard_deviation([-1,0,1]);"

I have shared the result of my experiments, so if you’re lazy repeating all the steps yourself, simply install a tweaked version the following way (but do this only if you can trust a anonymous stranger writing something in the comments):

sudo pecl install

Alexander Kachkaev said...

This bug has just been fixed permanently!


last archive