在Mac OS X上构建比特币时出现相同的错误

Getting same error when building bitcoind on Mac OS X

本文关键字:错误 OS Mac 构建      更新时间:2023-10-16

所以我在为OS X构建比特币的文档:https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md,每次我尝试构建时都有相同的错误。以下是我采取的步骤:

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/,我有Qt和qt5安装通过brew等。我不熟悉C/c++和编译代码,不知道下一步要尝试什么。提前感谢

首先尝试构建一个非gui的比特币:

make clean
./configure --without-gui
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/地窖/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,这是比特币核心的GUI版本从srcqt目录

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

我通过

对Makefile和src/Makefile进行更改(需要在每个。/configure之后重新做)来传递此错误

1:取下几个'-framework Qtxxxx',因为它们在同一行中与'-F path/to/qt/'有点冗余。

2:用"-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/sdk/MacOSX10.10"替换其余的"-framework"到一些基本的Apple库。sdk/系统/图书馆/框架"

但毕竟,我仍然放弃了qt gui,因为我遇到了下面链接中的确切问题,这似乎来自自制的qt5不适合x64,我懒得遵循这里的hack

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