Development

OSX Vanitygen 錯誤:pattern.c:32:10:致命錯誤:找不到“pcre.h”文件

  • March 3, 2014

當我嘗試按照“安裝”中列出的說明製作 vanitygen時出現以下錯誤

來自 make 的錯誤(短版)

27 warnings generated.
cc -ggdb -O3 -Wall   -c -o pattern.o pattern.c
pattern.c:32:10: fatal error: 'pcre.h' file not found
#include <pcre.h>
        ^
1 error generated.

make的完整輸出

my-MacBook-Pro:git-vanitygen admin$ make
cc -ggdb -O3 -Wall   -c -o vanitygen.o vanitygen.c
vanitygen.c:76:11: warning: 'EC_KEY_get0_group' is deprecated
     [-Wdeprecated-declarations]
       pgroup = EC_KEY_get0_group(pkey);
                ^
vanitygen.c:77:9: warning: 'EC_GROUP_get0_generator' is deprecated
     [-Wdeprecated-declarations]
       pgen = EC_GROUP_get0_generator(pgroup);
              ^
vanitygen.c:80:13: warning: 'EC_POINT_new' is deprecated
     [-Wdeprecated-declarations]
               ppnt[i] = EC_POINT_new(pgroup);
                         ^
vanitygen.c:86:14: warning: 'EC_POINT_new' is deprecated
     [-Wdeprecated-declarations]
       pbatchinc = EC_POINT_new(pgroup);
                   ^
vanitygen.c:92:2: warning: 'BN_set_word' is deprecated
     [-Wdeprecated-declarations]
       BN_set_word(&vxcp->vxc_bntmp, ptarraysize);
       ^
vanitygen.c:93:2: warning: 'EC_POINT_mul' is deprecated
     [-Wdeprecated-declarations]
       EC_POINT_mul(pgroup, pbatchinc, &vxcp->vxc_bntmp, NULL, NULL,
       ^
vanitygen.c:95:2: warning: 'EC_POINT_make_affine' is deprecated
     [-Wdeprecated-declarations]
       EC_POINT_make_affine(pgroup, pbatchinc, vxcp->vxc_bnctx);
       ^
vanitygen.c:124:4: warning: 'EC_KEY_generate_key' is deprecated
     [-Wdeprecated-declarations]
                       EC_KEY_generate_key(pkey);
                       ^
vanitygen.c:128:4: warning: 'EC_GROUP_get_order' is deprecated
     [-Wdeprecated-declarations]
                       EC_GROUP_get_order(pgroup, &vxcp->vxc_bntmp,
                       ^
vanitygen.c:130:4: warning: 'BN_sub' is deprecated [-Wdeprecated-declarations]
                       BN_sub(&vxcp->vxc_bntmp2,
                       ^
vanitygen.c:132:11: warning: 'EC_KEY_get0_private_key' is deprecated
     [-Wdeprecated-declarations]
                              EC_KEY_get0_private_key(pkey));
                              ^
vanitygen.c:133:15: warning: 'BN_get_word' is deprecated
     [-Wdeprecated-declarations]
                       rekey_at = BN_get_word(&vxcp->vxc_bntmp2);
                                  ^
vanitygen.c:138:4: warning: 'EC_POINT_copy' is deprecated
     [-Wdeprecated-declarations]
                       EC_POINT_copy(ppnt[0], EC_KEY_get0_public_key(pkey));
                       ^
vanitygen.c:138:27: warning: 'EC_KEY_get0_public_key' is deprecated
     [-Wdeprecated-declarations]
                       EC_POINT_copy(ppnt[0], EC_KEY_get0_public_key(pkey));
                                              ^
vanitygen.c:145:5: warning: 'EC_POINT_add' is deprecated
     [-Wdeprecated-declarations]
                               EC_POINT_add(pgroup,
                               ^
vanitygen.c:154:5: warning: 'EC_POINT_add' is deprecated
     [-Wdeprecated-declarations]
                               EC_POINT_add(pgroup,
                               ^
vanitygen.c:173:5: warning: 'EC_POINT_add' is deprecated
     [-Wdeprecated-declarations]
                               EC_POINT_add(pgroup,
                               ^
vanitygen.c:192:3: warning: 'EC_POINTs_make_affine' is deprecated
     [-Wdeprecated-declarations]
               EC_POINTs_make_affine(pgroup, nbatch, ppnt, vxcp->vxc_bnctx);
               ^
vanitygen.c:196:10: warning: 'EC_POINT_point2oct' is deprecated
     [-Wdeprecated-declarations]
                       len = EC_POINT_point2oct(pgroup, ppnt[i],
                             ^
vanitygen.c:203:4: warning: 'SHA256' is deprecated [-Wdeprecated-declarations]
                       SHA256(hash_buf, hash_len, hash1);
                       ^
vanitygen.c:204:4: warning: 'RIPEMD160' is deprecated
     [-Wdeprecated-declarations]
                       RIPEMD160(hash1, sizeof(hash1), &vxcp->vxc_binres[1]);
                       ^
vanitygen.c:236:4: warning: 'EC_POINT_free' is deprecated
     [-Wdeprecated-declarations]
                       EC_POINT_free(ppnt[i]);
                       ^
vanitygen.c:238:3: warning: 'EC_POINT_free' is deprecated
     [-Wdeprecated-declarations]
               EC_POINT_free(pbatchinc);
               ^
vanitygen.c:419:18: warning: 'EC_POINT_hex2point' is deprecated
     [-Wdeprecated-declarations]
                       pubkey_base = EC_POINT_hex2point(
                                     ^
vanitygen.c:420:5: warning: 'EC_KEY_get0_group' is deprecated
     [-Wdeprecated-declarations]
                               EC_KEY_get0_group(pkey),
                               ^
vanitygen.c:422:4: warning: 'EC_KEY_free' is deprecated
     [-Wdeprecated-declarations]
                       EC_KEY_free(pkey);
                       ^
vanitygen.c:528:9: warning: 'RAND_load_file' is deprecated
     [-Wdeprecated-declarations]
               opt = RAND_load_file(seedfile, opt);
                     ^
27 warnings generated.
cc -ggdb -O3 -Wall   -c -o pattern.o pattern.c
pattern.c:32:10: fatal error: 'pcre.h' file not found
#include <pcre.h>
        ^
1 error generated.
make: *** [pattern.o] Error 1

更新

我懷疑列出的 PCRE也有一個在這裡列出的 OSX 埠,當我按照說明編譯時,我得到了這個錯誤:

make  install-am
./install-sh -c -d '/usr/local/lib'
/bin/sh ./libtool   --mode=install /usr/bin/install -c   libpcre.la libpcreposix.la libpcrecpp.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libpcre.1.dylib /usr/local/lib/libpcre.1.dylib
install: /usr/local/lib/libpcre.1.dylib: Permission denied
make[2]: *** [install-libLTLIBRARIES] Error 71
make[1]: *** [install-am] Error 2
make: *** [install] Error 2

我建議使用 Homebrew 或 MacPorts 來管理這種依賴關係。

Homebrew 包是簡單的pcrepcre++.

brew install pcre pcre++

MacPorts 包是pcrepcrexx.

sudo port install pcre pcrexx

以防萬一有人仍在尋找答案:在 pattern.c 中,只需將完整路徑放入 pcre.h (使用 locate pcre.h 為其查找路徑;如果您沒有該文件,只需先安裝 pcre 包) . 之後應該可以正常編譯。

引用自:https://bitcoin.stackexchange.com/questions/5697