在 Mac OS X 上构建 bitcoind 时出现相同的错误

Getting same error when building bitcoind on Mac OS X

所以我在为 OS X: https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md 构建 bitcoind 的文档上,每次尝试构建时我都会遇到同样的错误。以下是我采取的步骤:

brew install autoconf automake berkeley-db4 libtool boost miniupnpc openssl pkg-config protobuf qt5

git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin

./autogen.sh
./configure --with-gui=qt5
make

这是我得到的错误:

OBJCXXLD qt/bitcoin-qt
clang: error: unknown argument: '-framework QtNetwork'
clang: error: unknown argument: '-framework QtWidgets'
clang: error: unknown argument: '-framework QtGui'
clang: error: unknown argument: '-framework QtCore'
clang: error: unknown argument: '-framework QtDBus'
clang: error: unknown argument: '-framework QtCore'
make[2]: *** [qt/bitcoin-qt] Error 1
make[1]: *** [check-recursive] Error 1
make: *** [check-recursive] Error 1

我已经用谷歌搜索了一天多了。我在这里手动下载了开源 Qt:http://www.qt.io/download-open-source/,我通过 brew 等安装了 qt 和 qt5。我对 C/C++ 和编译代码不太熟悉,不知道是什么接下来试试。提前致谢

首先尝试构建一个非 GUI bitcoind:

make clean
./configure --without-gui
make

我通过对 Makefile 进行更改(需要在每次 ./configure 之后重做)并通过

src/Makefile 传递了这个错误

1: Taking off the several '-framework Qtxxxx's, since they are kind of redundant with the '-F path/to/qt/' in same line.

2: Replacing the rest '-framework's to some basic Apple libraries with '-F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks'

但毕竟我还是放弃了qt gui,因为我遇到了如下确切的问题link,看来自制软件的qt5不适用于x64,我懒得跟上了这里的黑客

https://github.com/bitcoin/bitcoin/issues/5728

我遇到了同样的问题,通过切换回 qt4 并在没有 GUI 的情况下进行编译解决了这个问题:

brew install autoconf automake berkeley-db4 libtool boost miniupnpc openssl pkg-config protobuf qt4

git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin

./autogen.sh
./configure
make

我有同样的错误...我通过手动编辑 MakeFile

解决了这个问题

问题出在下面的 QT_DBUS_LIBS, QT_LIBS and QT_TEST_LIBS 定义中... -F flag and -framework 是导致问题的原因。

QT_DBUS_LIBS = -F/usr/local/Cellar/qt5/5.5.0/lib -framework\ QtDBus -F/usr/local/Cellar/qt5/5.5.0/lib -framework\ QtCore 
QT_LIBS = -F/usr/local/Cellar/qt5/5.5.0/lib/QtNetwork -F/usr/local/Cellar/qt5/5.5.0/lib -framework\ QtWidgets -F/usr/local/Cellar/qt5/5.5.0/lib -framework\ QtGui -F/usr/local/Cellar/qt5/5.5.0/lib -framework\ QtCore  -framework Foundation -framework ApplicationServices -framework AppKit
QT_TEST_LIBS = -F/usr/local/Cellar/qt5/5.5.0/lib -framework\ QtTest -F/usr/local/Cellar/qt5/5.5.0/lib -framework\ QtCore 

将这些库名称替换为对库的直接引用...你必须首先找到你的 Qt 库路径,我的在 /usr/local/Cellar/qt5/5.5.0/lib

QT_DBUS_LIBS = /usr/local/Cellar/qt5/5.5.0/lib/QtDBus.framework/QtDBus /usr/local/Cellar/qt5/5.5.0/lib/QtCore.framework/QtCore
QT_LIBS = /usr/local/Cellar/qt5/5.5.0/lib/QtNetwork.framework/QtNetwork /usr/local/Cellar/qt5/5.5.0/lib/QtWidgets.framework/QtWidgets /usr/local/Cellar/qt5/5.5.0/lib/QtGui.framework/QtGui /usr/local/Cellar/qt5/5.5.0/lib/QtCore.framework/QtCore  -framework Foundation -framework ApplicationServices -framework AppKit
QT_TEST_LIBS = /usr/local/Cellar/qt5/5.5.0/lib/QtTest.framework/QtTest /usr/local/Cellar/qt5/5.5.0/lib/QtCore.framework/QtCore

更改后

make clean
make

效果很好!

运行 bitcoin-qt 是来自 src\qt 目录

的比特币核心的 GUI 版本

玩得开心!请记住,如果您再次 运行 configure,这些更改将被覆盖。