guanzhi / GmSSL

支持国密SM2/SM3/SM4/SM9/SSL的密码工具箱
http://gmssl.org
Apache License 2.0
5.19k stars 1.67k forks source link

go build报错 #798

Closed denept closed 5 years ago

denept commented 5 years ago

您好,我在执行go build后显示如下错误信息, 系统centos7,go versin 1.12.5,gmssl 和测试文件都是最新的 请问如何解决

gmssl

./pkey.go:948:34: could not determine kind of name for C.EVP_sm3 cgo: gcc errors for preamble: ./pkey.go:105:2: error: 'NID_sm2sign' undeclared here (not in a function); did you mean 'NID_ns_sgc'? NID_sm2sign, ^~~ NID_ns_sgc ./pkey.go: In function 'get_sign_info': ./pkey.go:133:15: error: 'NID_sm_scheme' undeclared (first use in this function); did you mean 'ec_scheme'? ec_scheme = NID_sm_scheme; ^~~~~ ec_scheme ./pkey.go:133:15: note: each undeclared identifier is reported only once for each function it appears in ./pkey.go:137:15: error: 'NID_secg_scheme' undeclared (first use in this function); did you mean 'OBJ_secg_scheme'? ec_scheme = NID_secg_scheme; ^~~~~~~ OBJ_secg_scheme ./pkey.go: At top level: ./pkey.go:186:2: error: 'NID_ecies_recommendedParameters' undeclared here (not in a function) NID_ecies_recommendedParameters, ^~~~~~~ ./pkey.go:186:2: error: initializer element is not constant ./pkey.go:186:2: note: (near initialization for 'pke_nids[1]') ./pkey.go:187:2: error: 'NID_ecies_specifiedParameters' undeclared here (not in a function) NID_ecies_specifiedParameters, ^~~~~~~~~ ./pkey.go:187:2: error: initializer element is not constant ./pkey.go:187:2: note: (near initialization for 'pke_nids[2]') ./pkey.go:189:2: error: 'NID_ecies_with_x9_63_sha1_xor_hmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha1_xor_hmac, ^~~~~~~~~~ ./pkey.go:189:2: error: initializer element is not constant ./pkey.go:189:2: note: (near initialization for 'pke_nids[3]') ./pkey.go:190:2: error: 'NID_ecies_with_x9_63_sha256_xor_hmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha256_xor_hmac, ^~~~~~~~ ./pkey.go:190:2: error: initializer element is not constant ./pkey.go:190:2: note: (near initialization for 'pke_nids[4]') ./pkey.go:191:2: error: 'NID_ecies_with_x9_63_sha512_xor_hmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha512_xor_hmac, ^~~~~~~~ ./pkey.go:191:2: error: initializer element is not constant ./pkey.go:191:2: note: (near initialization for 'pke_nids[5]') ./pkey.go:192:2: error: 'NID_ecies_with_x9_63_sha1_aes128_cbc_hmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha1_aes128_cbc_hmac, ^~~~~~~~~ ./pkey.go:192:2: error: initializer element is not constant ./pkey.go:192:2: note: (near initialization for 'pke_nids[6]') ./pkey.go:193:2: error: 'NID_ecies_with_x9_63_sha256_aes128_cbc_hmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha256_aes128_cbc_hmac, ^~~~~~~~~~~ ./pkey.go:193:2: error: initializer element is not constant ./pkey.go:193:2: note: (near initialization for 'pke_nids[7]') ./pkey.go:194:2: error: 'NID_ecies_with_x9_63_sha512_aes256_cbc_hmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha512_aes256_cbc_hmac, ^~~~~~~~~~~ ./pkey.go:194:2: error: initializer element is not constant ./pkey.go:194:2: note: (near initialization for 'pke_nids[8]') ./pkey.go:195:2: error: 'NID_ecies_with_x9_63_sha256_aes128_ctr_hmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha256_aes128_ctr_hmac, ^~~~~~~~~~~ ./pkey.go:195:2: error: initializer element is not constant ./pkey.go:195:2: note: (near initialization for 'pke_nids[9]') ./pkey.go:196:2: error: 'NID_ecies_with_x9_63_sha512_aes256_ctr_hmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha512_aes256_ctr_hmac, ^~~~~~~~~~~ ./pkey.go:196:2: error: initializer element is not constant ./pkey.go:196:2: note: (near initialization for 'pke_nids[10]') ./pkey.go:197:2: error: 'NID_ecies_with_x9_63_sha256_aes128_cbc_hmac_half' undeclared here (not in a function) NID_ecies_with_x9_63_sha256_aes128_cbc_hmac_half, ^~~~~~~~~~~~ ./pkey.go:197:2: error: initializer element is not constant ./pkey.go:197:2: note: (near initialization for 'pke_nids[11]') ./pkey.go:198:2: error: 'NID_ecies_with_x9_63_sha512_aes256_cbc_hmac_half' undeclared here (not in a function) NID_ecies_with_x9_63_sha512_aes256_cbc_hmac_half, ^~~~~~~~~~~~ ./pkey.go:198:2: error: initializer element is not constant ./pkey.go:198:2: note: (near initialization for 'pke_nids[12]') ./pkey.go:199:2: error: 'NID_ecies_with_x9_63_sha256_aes128_ctr_hmac_half' undeclared here (not in a function) NID_ecies_with_x9_63_sha256_aes128_ctr_hmac_half, ^~~~~~~~~~~~ ./pkey.go:199:2: error: initializer element is not constant ./pkey.go:199:2: note: (near initialization for 'pke_nids[13]') ./pkey.go:200:2: error: 'NID_ecies_with_x9_63_sha512_aes256_ctr_hmac_half' undeclared here (not in a function) NID_ecies_with_x9_63_sha512_aes256_ctr_hmac_half, ^~~~~~~~~~~~ ./pkey.go:200:2: error: initializer element is not constant ./pkey.go:200:2: note: (near initialization for 'pke_nids[14]') ./pkey.go:201:2: error: 'NID_ecies_with_x9_63_sha1_aes128_cbc_cmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha1_aes128_cbc_cmac, ^~~~~~~~~ ./pkey.go:201:2: error: initializer element is not constant ./pkey.go:201:2: note: (near initialization for 'pke_nids[15]') ./pkey.go:202:2: error: 'NID_ecies_with_x9_63_sha256_aes128_cbc_cmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha256_aes128_cbc_cmac, ^~~~~~~~~~~ ./pkey.go:202:2: error: initializer element is not constant ./pkey.go:202:2: note: (near initialization for 'pke_nids[16]') ./pkey.go:203:2: error: 'NID_ecies_with_x9_63_sha512_aes256_cbc_cmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha512_aes256_cbc_cmac, ^~~~~~~~~~~ ./pkey.go:203:2: error: initializer element is not constant ./pkey.go:203:2: note: (near initialization for 'pke_nids[17]') ./pkey.go:204:2: error: 'NID_ecies_with_x9_63_sha256_aes128_ctr_cmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha256_aes128_ctr_cmac, ^~~~~~~~~~~ ./pkey.go:204:2: error: initializer element is not constant ./pkey.go:204:2: note: (near initialization for 'pke_nids[18]') ./pkey.go:205:2: error: 'NID_ecies_with_x9_63_sha512_aes256_ctr_cmac' undeclared here (not in a function) NID_ecies_with_x9_63_sha512_aes256_ctr_cmac, ^~~~~~~~~~~ ./pkey.go:205:2: error: initializer element is not constant ./pkey.go:205:2: note: (near initialization for 'pke_nids[19]') ./pkey.go:209:2: error: 'NID_sm2encrypt_with_sm3' undeclared here (not in a function) NID_sm2encrypt_with_sm3, ^~~~~~~ ./pkey.go:209:2: error: initializer element is not constant ./pkey.go:209:2: note: (near initialization for 'pke_nids[20]') ./pkey.go:211:2: error: 'NID_sm2encrypt_with_sha1' undeclared here (not in a function); did you mean 'NID_ecdsa_with_SHA1'? NID_sm2encrypt_with_sha1, ^~~~~~~~ NID_ecdsa_with_SHA1 ./pkey.go:211:2: error: initializer element is not constant ./pkey.go:211:2: note: (near initialization for 'pke_nids[21]') ./pkey.go:212:2: error: 'NID_sm2encrypt_with_sha256' undeclared here (not in a function); did you mean 'NID_ecdsa_with_SHA256'? NID_sm2encrypt_with_sha256, ^~~~~~ NID_ecdsa_with_SHA256 ./pkey.go:212:2: error: initializer element is not constant ./pkey.go:212:2: note: (near initialization for 'pke_nids[22]') ./pkey.go:213:2: error: 'NID_sm2encrypt_with_sha512' undeclared here (not in a function); did you mean 'NID_ecdsa_with_SHA512'? NID_sm2encrypt_with_sha512, ^~~~~~ NID_ecdsa_with_SHA512 ./pkey.go:213:2: error: initializer element is not constant ./pkey.go:213:2: note: (near initialization for 'pke_nids[23]') ./pkey.go: In function 'get_pke_info': ./pkey.go:249:15: error: 'NID_secg_scheme' undeclared (first use in this function); did you mean 'OBJ_secg_scheme'? ec_scheme = NID_secg_scheme; ^~~~~~~ OBJ_secg_scheme ./pkey.go:254:15: error: 'NID_sm_scheme' undeclared (first use in this function); did you mean 'ec_scheme'? ec_scheme = NID_sm_scheme; ^~~~~ ec_scheme ./pkey.go:255:22: error: 'NID_sm3' undeclared (first use in this function); did you mean 'NID_sha'? ec_encrypt_param = NID_sm3; ^~~ NID_sha ./pkey.go: At top level: ./pkey.go:285:2: error: 'NID_sm2exchange' undeclared here (not in a function); did you mean 'NID_clearance'? NID_sm2exchange, ^~~~~~~ NID_clearance ./pkey.go:285:2: error: initializer element is not constant ./pkey.go:285:2: note: (near initialization for 'exch_nids[0]') ./pkey.go: In function 'get_exch_info': ./pkey.go:320:15: error: 'NID_sm_scheme' undeclared (first use in this function); did you mean 'ec_scheme'? ec_scheme = NID_sm_scheme; ^~~~~ ec_scheme ./pkey.go:321:17: error: 'NID_sm3' undeclared (first use in this function); did you mean 'NID_sha'? ecdh_kdf_md = NID_sm3; ^~~ NID_sha ./pkey.go:325:15: error: 'NID_secg_scheme' undeclared (first use in this function); did you mean 'OBJ_secg_scheme'? ec_scheme = NID_secg_scheme; ^~~~~~~ OBJ_secg_scheme ./pkey.go: In function 'pk_encrypt': ./pkey.go:421:51: error: 'NID_sm2p256v1' undeclared (first use in this function); did you mean 'NID_secp256k1'? EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(pk))) == NID_sm2p256v1) { ^~~~~ NID_secp256k1 ./pkey.go: In function 'sk_decrypt': ./pkey.go:465:51: error: 'NID_sm2p256v1' undeclared (first use in this function); did you mean 'NID_secp256k1'? EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(sk))) == NID_sm2p256v1) { ^~~~~ NID_secp256k1 ./pkey.go: In function 'sk_sign': ./pkey.go:501:51: error: 'NID_sm2p256v1' undeclared (first use in this function); did you mean 'NID_secp256k1'? EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(sk))) == NID_sm2p256v1) { ^~~~~ NID_secp256k1 In file included from ./pkey.go:57: ./pkey.go:502:39: error: 'NID_sm_scheme' undeclared (first use in this function); did you mean 'BIO_s_secmem'? if (EVP_PKEY_CTX_set_ec_scheme(ctx, NID_sm_scheme) <= 0) { ^~~~~ ./pkey.go: In function 'pk_verify': ./pkey.go:539:51: error: 'NID_sm2p256v1' undeclared (first use in this function); did you mean 'NID_secp256k1'? EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(pk))) == NID_sm2p256v1) { ^~~~~ NID_secp256k1 In file included from ./pkey.go:57: ./pkey.go:540:39: error: 'NID_sm_scheme' undeclared (first use in this function); did you mean 'BIO_s_secmem'? if (EVP_PKEY_CTX_set_ec_scheme(ctx, NID_sm_scheme) <= 0) { ^~~~~

denept commented 5 years ago

已解决,需要编译gmssl