在 linux 上编译比特币源代码 (https://github.com/bitcoin/bitcoin) 时出现问题

问题描述

问题:从 https://github.com/bitcoin/bitcoin 编译比特币源代码时出现问题

构建比特币代码需要 Berkeley DB 4.8(https://github.com/tinybike/get-bdb-4.8)。 没问题。

我的系统在 Ubuntu 20.04 上运行。

$ cpp --version
cpp (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
copyright (C) 2019 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or fitness FOR A PARTIculaR PURPOSE.

$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
copyright (C) 2019 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or fitness FOR A PARTIculaR PURPOSE.

$ g++ --version
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
copyright (C) 2019 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or fitness FOR A PARTIculaR PURPOSE.

编译比特币代码时,运行'configure'和'make'后出现错误提示找不到iostream.h

...
  CXX      libbitcoin_server_a-txrequest.o
  CXX      libbitcoin_server_a-txmempool.o
  CXX      libbitcoin_server_a-validation.o
  CXX      libbitcoin_server_a-validationinterface.o
  CXX      libbitcoin_server_a-versionbits.o
  CXX      wallet/libbitcoin_server_a-init.o
In file included from ./wallet/bdb.h:27,from wallet/init.cpp:19:
/bitcoin/src/bdb/build_unix/build/include/db_cxx.h:59:10: Fatal error: iostream.h: No such file or directory
   59 | #include <iostream.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:8933: wallet/libbitcoin_server_a-init.o] Error 1
make[2]: Leaving directory '/bitcoin/src'
make[1]: *** [Makefile:15214: all-recursive] Error 1
make[1]: Leaving directory '/bitcoin/src'
make: *** [Makefile:809: all-recursive] Error 1

在检查头文件位置 /usr/include/c++/9 时我找不到 iostream.h

这是编译器包问题还是比特币没有使用 c++ iostream 头文件

解决方法

我猜您在安装所需的系统包之前尝试构建“depends”BDB,这产生了无效/无法使用的构建。

尝试删除您当前的“依赖”构建并重新构建。

或者,您可以将我的 db48 PPA 用于 Ubuntu:https://launchpad.net/~luke-jr/+archive/ubuntu/db48

,

我遇到了同样的错误,但它是在我用 berkeley db 构建零冰时出现的。我发现了一些关于 libdb 的用法,其中大部分在代码的开头添加了 #define HAVE_CXX_STDHEADERS,所以我尝试在 ICEDIR/cpp/include/IceUtil/Config.h 中添加这个定义。它有效。希望它对你有效。