Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

macos - Install PHP gnupg using PECL on MAC/MAMP 10.8.4

I am trying to install gnupg on a mac using PECL.

sudo pecl install gnupg

downloading gnupg-1.3.3.tgz ...
Starting to download gnupg-1.3.3.tgz (19,141 bytes)
......done: 19,141 bytes
5 source files, building
WARNING: php_bin /Applications/MAMP/bin/php/php5.5.3/bin/php appears to have a suffix /php5.5.3/bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212
building in /private/tmp/pear/install/pear-build-rootj1cVj1/gnupg-1.3.3
running: /private/tmp/pear/install/gnupg/configure
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /opt/local/bin/gsed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin12.4.0
checking host system type... x86_64-apple-darwin12.4.0
checking target system type... x86_64-apple-darwin12.4.0
checking for PHP prefix... /Applications/MAMP/bin/php/php5.5.3
checking for PHP includes... -I/Applications/MAMP/bin/php/php5.5.3/include/php -I/Applications/MAMP/bin/php/php5.5.3/include/php/main -I/Applications/MAMP/bin/php/php5.5.3/include/php/TSRM -I/Applications/MAMP/bin/php/php5.5.3/include/php/Zend -I/Applications/MAMP/bin/php/php5.5.3/include/php/ext -I/Applications/MAMP/bin/php/php5.5.3/include/php/ext/date/lib
checking for PHP extension directory... /Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212
checking for PHP installed headers prefix... /Applications/MAMP/bin/php/php5.5.3/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for gnupg support... yes, shared
checking for gnupg files in default path... not found
configure: error: Please reinstall the gpgme distribution
ERROR: `/private/tmp/pear/install/gnupg/configure' failed

I have narrowed down my problem to getting gpgme installed, but I can't find the correct way to to do it anywhere.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:

  1. Download the gnupg-pecl module:

    pecl download gnupg
    
  2. Unpack the gnupg-pecl module:

    tar xvf gnupg-1.3.3.tgz
    
  3. Change directory:

    cd gnupg-1.3.3
    
  4. Modify php_gnupg.h by changing line 49:

    zend_class_entry *gnupg_class_entry; into static zend_class_entry *gnupg_class_entry;

  5. 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.

  1. Prepare the PHP module for compiling, run:

    phpize
    
  2. Configure the module:

    ./configure
    
  3. Build the module:

    make
    
  4. Install the module:

    make install 
    
  5. 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/
    
  6. Add the extension to PHP. Therefore open /etc/php.ini and add the following lines:

     [gnupg]
     extension=gnupg.so
    
  7. Test the extension, by executing the following line:

     php -r "print_r(new gnupg());"
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...