当我编译代码时,我收到一个错误,告诉我我的'EC_GROUP_set_curve_GF2m'函数未在此范围内声明。我已经研究了错误信息,我无法弄清楚如何解决它。
My Centos 7是新安装并安装的软件包:
sudo yum install -y automake autoconf libtool g++ libssl-dev cmake libbz2-dev python
错误信息:
/home/bubichain-v3/src/utils/ecc_sm2.cpp: In static member function ‘static EC_GROUP* utils::EccSm2::NewGroup(utils::EccSm2::GROUP_TYPE, std::string, std::string, std::string, std::string, std::string, std::string)’:
/home/bubichain-v3/src/utils/ecc_sm2.cpp:211:48: error: ‘EC_GF2m_simple_method’ was not declared in this scope
group = EC_GROUP_new(EC_GF2m_simple_method());
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp:216:53: error: ‘EC_GROUP_set_curve_GF2m’ was not declared in this scope
if (!EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) {
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp:221:63: error: ‘EC_POINT_set_affine_coordinates_GF2m’ was not declared in this scope
EC_POINT_set_affine_coordinates_GF2m(group, G, xG, yG, ctx);
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp: In static member function ‘static std::string utils::EccSm2::getZA(EC_GROUP*, std::string, const EC_POINT*)’:
/home/bubichain-v3/src/utils/ecc_sm2.cpp:255:66: error: ‘EC_POINT_get_affine_coordinates_GF2m’ was not declared in this scope
EC_POINT_get_affine_coordinates_GF2m(group, pkey, xA, yA, NULL);
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp:264:62: error: ‘EC_POINT_get_affine_coordinates_GF2m’ was not declared in this scope
EC_POINT_get_affine_coordinates_GF2m(group, G, xG, yG, ctx);
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp: In member function ‘bool utils::EccSm2::From(std::string)’:
/home/bubichain-v3/src/utils/ecc_sm2.cpp:334:71: error: ‘EC_POINT_get_affine_coordinates_GF2m’ was not declared in this scope
if (!EC_POINT_get_affine_coordinates_GF2m(group_, pkey_, x, y, ctx)) {
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp: In member function ‘bool utils::EccSm2::NewRandom()’:
/home/bubichain-v3/src/utils/ecc_sm2.cpp:376:71: error: ‘EC_POINT_get_affine_coordinates_GF2m’ was not declared in this scope
if (!EC_POINT_get_affine_coordinates_GF2m(group_, pkey_, x, y, ctx)) {
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp: In member function ‘std::string utils::EccSm2::Sign(const string&, const string&)’:
/home/bubichain-v3/src/utils/ecc_sm2.cpp:473:74: error: ‘EC_POINT_get_affine_coordinates_GF2m’ was not declared in this scope
if (!EC_POINT_get_affine_coordinates_GF2m(group_, pt1, x1, NULL, ctx)) {
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp: In static member function ‘static int utils::EccSm2::verify(EC_GROUP*, const string&, const string&, const string&, const string&)’:
/home/bubichain-v3/src/utils/ecc_sm2.cpp:586:69: error: ‘EC_POINT_set_affine_coordinates_GF2m’ was not declared in this scope
EC_POINT_set_affine_coordinates_GF2m(group, pub_key, xp, yp, NULL);
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp:643:73: error: ‘EC_POINT_get_affine_coordinates_GF2m’ was not declared in this scope
if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x1, NULL, ctx)) {
^
/home/bubichain-v3/src/utils/ecc_sm2.cpp: In member function ‘std::string utils::EccSm2::GetPublicKey()’:
/home/bubichain-v3/src/utils/ecc_sm2.cpp:698:72: error: ‘EC_POINT_get_affine_coordinates_GF2m’ was not declared in this scope
EC_POINT_get_affine_coordinates_GF2m(group_, pkey_, bn_x, bn_y, NULL);
^
make[3]: *** [utils/CMakeFiles/bubi_utils.dir/ecc_sm2.cpp.o] Error 1
make[3]: Leaving directory `/home/bubichain-v3/build/linux'
make[2]: *** [utils/CMakeFiles/bubi_utils.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
/usr/bin/cmake -E cmake_progress_report /home/bubichain-v3/build/linux/CMakeFiles 44
答案 0 :(得分:0)
此解决方案对我有用:
步骤1:我假设您当前的工作目录是Ruby源目录。
步骤2:下载补丁,如下所示:
# wget https://bugs.ruby-lang.org/attachments/download/3707/out.patch
# ls out.patch
out.patch
# find . -name ossl_pkey_ec.c
./ext/openssl/ossl_pkey_ec.c
步骤4:运行下载的补丁
# patch ./ext/openssl/ossl_pkey_ec.c < out.patch
patching file ./ext/openssl/ossl_pkey_ec.c
Hunk #1 succeeded at 757 (offset -5 lines).
Hunk #2 succeeded at 814 (offset -5 lines).
patching file ./ext/openssl/ossl_pkey_ec.c
Hunk #1 FAILED at 7.
1 out of 1 hunk FAILED -- saving rejects to file ./ext/openssl/ossl_pkey_ec.c.rej