c++ - 聚合 ‘BIGNUM foo’ 类型不完整,无法定义

标签 c++ makefile openssl

我尝试编译 opendcp , 但发生错误。

$ make

...

[ 10%] Building CXX object libasdcp/CMakeFiles/opendcp-asdcp.dir/KM_prng.cpp.o
/home/jwel/opendcp/libasdcp/KM_prng.cpp: In function ‘void Kumu::Gen_FIPS_186_Value(const byte_t*, ui32_t, byte_t*, ui32_t)’:
/home/jwel/opendcp/libasdcp/KM_prng.cpp:219:10: error: aggregate ‘BIGNUM c_2powb’ has incomplete type and cannot be defined
   BIGNUM c_2powb, c_2, c_b;
          ^~~~~~~
/home/jwel/opendcp/libasdcp/KM_prng.cpp:219:19: error: aggregate ‘BIGNUM c_2’ has incomplete type and cannot be defined
   BIGNUM c_2powb, c_2, c_b;
                   ^~~
/home/jwel/opendcp/libasdcp/KM_prng.cpp:219:24: error: aggregate ‘BIGNUM c_b’ has incomplete type and cannot be defined
   BIGNUM c_2powb, c_2, c_b;
                        ^~~
/home/jwel/opendcp/libasdcp/KM_prng.cpp:220:19: error: ‘BN_init’ was not declared in this scope
   BN_init(&c_2powb);  BN_init(&c_2);  BN_init(&c_b);
                   ^
/home/jwel/opendcp/libasdcp/KM_prng.cpp:248:14: error: aggregate ‘BIGNUM bn_tmp’ has incomplete type and cannot be defined
       BIGNUM bn_tmp, bn_xkey, bn_x_n;
              ^~~~~~
/home/jwel/opendcp/libasdcp/KM_prng.cpp:248:22: error: aggregate ‘BIGNUM bn_xkey’ has incomplete type and cannot be defined
       BIGNUM bn_tmp, bn_xkey, bn_x_n;
                      ^~~~~~~
/home/jwel/opendcp/libasdcp/KM_prng.cpp:248:31: error: aggregate ‘BIGNUM bn_x_n’ has incomplete type and cannot be defined
       BIGNUM bn_tmp, bn_xkey, bn_x_n;
                               ^~~~~~
libasdcp/CMakeFiles/opendcp-asdcp.dir/build.make:110: recipe for target 'libasdcp/CMakeFiles/opendcp-asdcp.dir/KM_prng.cpp.o' failed
make[2]: *** [libasdcp/CMakeFiles/opendcp-asdcp.dir/KM_prng.cpp.o] Error 1
make[1]: *** [libasdcp/CMakeFiles/opendcp-asdcp.dir/all] Error 2
make: *** [all] Error 2

这对我来说似乎是 openssl 问题,所以我尝试对此进行测试:

$ cat testBIGNUM.cpp
#include <openssl/bn.h>
int main(){
    BIGNUM bn;
}

$ g++ testBIGNUM.cpp
testBIGNUM.cpp: In function ‘int main()’:
testBIGNUM.cpp:4:9: error: aggregate ‘BIGNUM bn’ has incomplete type and cannot be defined
  BIGNUM bn;
         ^~

我的 openssl 版本是 1.1.0d-2,我不知道如何修复它。

最佳答案

OpenSSL 1.0.2 和 OpenSSL 1.1.0 之间有很大的变化,它们不是完全源兼容的。特别是 1.0.2 头文件中的许多数据结构现在是不透明的。使用 OpenSSL 的应用程序需要进行一些小的更改才能兼容。

如果是 BIGNUM,你需要这样做:

#include <openssl/bn.h>
int main() {
    BIGNUM *bn;

    bn = BN_new();

    ...
    BN_free(bn);

    return 0;
}

对于 opendcp,答案可能是降级到 OpenSSL 1.0.2。

关于c++ - 聚合 ‘BIGNUM foo’ 类型不完整,无法定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42292027/

相关文章:

c++ - 替换派生对象 vector 中的对象 "no matching function to call"

c++ - CFLAGS 并分配多个引用?

c++ - 使用 aes_256_cbc 密码加密时的默认 IV 是什么?

MongoDB 3.0.5 错误 : symbol lookup error: undefined symbol: FIPS_mode_set

python - 阻止 OpenSSL 使用系统证书?

c++ LoadLibrary() 导致程序退出

c++ - 重载下标运算符不返回指针

c++ - 围绕世界 0,0,0 而不是对象中心旋转

makefile - 在 Makefile 中使用 Clang++ 代替 G++

Linux 模块 makefile 编译错误