I was facing the same problem, when using PHP 5.4.24, Mac OSX 10.9.3. I had to take the following steps to install gnupg (v1.3.3) using PECL.
Firstly, I installed the software packages gnupg
and gpgme
using homebrew. Homebrew installs your packages in /usr/local
. This is import because the gnupg PECL module searches the following locations /usr/local/include /usr/include /usr/local/include/gpgme/ /usr/include/gpgme/
to detect an installation of gpgpme
.
Secondly, I tried to install gnupgp using PECL:
pecl install gnupg
At time writing, the code of the PECL module contains two statement that prevents the module from being compiled and linked correctly. This resulted into the following error:
...compile statements...
cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/gnupg.so -bundle .libs/gnupg.o .libs/gnupg_keylistiterator.o -L/usr/local/include/lib -lgpgme -Wl,-rpath -Wl,/usr/local/include/lib
ld: warning: directory not found for option '-L/usr/local/include/lib'
duplicate symbol _gnupg_keylistiterator_class_entry in:
.libs/gnupg.o
.libs/gnupg_keylistiterator.o
duplicate symbol _gnupg_class_entry in:
.libs/gnupg.o
.libs/gnupg_keylistiterator.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [gnupg.la] Error 1
Thirdly, I had to resolve this error by editing and installing the PECL module by hand, based on Jim Jagielski's patch. These are the steps I completed:
Download the gnupg-pecl module:
pecl download gnupg
Unpack the gnupg-pecl module:
tar xvf gnupg-1.3.3.tgz
Change directory:
cd gnupg-1.3.3
Modify php_gnupg.h
by changing line 49:
zend_class_entry *gnupg_class_entry;
into static zend_class_entry *gnupg_class_entry;
Modify php_gnupg_keylistiterator.h
by changing line 44:
zend_class_entry *gnupg_keylistiterator_class_entry;
into static zend_class_entry *gnupg_keylistiterator_class_entry;
Step 4 and 5 are not required on gnupg-1.4.0 or greater.
Prepare the PHP module for compiling, run:
phpize
Configure the module:
./configure
Build the module:
make
Install the module:
make install
After compiling the module was installed in /Users/USERNAME/tmp/pear/install/gnupg-1.3.3/module
. Because the PHP shared extensions are installed in /usr/lib/php/extensions/no-debug-non-zts-20100525/
, I copied the module:
cp /Users/USERNAME/tmp/pear/install/gnupg-1.3.3/modules/gnupg.so /usr/lib/php/extensions/no-debug-non-zts-20100525/
Add the extension to PHP. Therefore open /etc/php.ini
and add the following lines:
[gnupg]
extension=gnupg.so
Test the extension, by executing the following line:
php -r "print_r(new gnupg());"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…