提问人:Lepu Tenty 提问时间:2/14/2021 更新时间:2/15/2021 访问量:341
由于未定义对 Boost 和事件库的引用而无法编译?
Unable to compile due to Undefined Reference to Boost and Event Libraries?
问:
当尝试使用以下配置命令编译比特币核心时,它不起作用。
EVENT_PTHREADS_CFLAGS='-I/usr/lib/i386-linux-gnu' EVENT_PTHREADS_LIBS='-L/usr/lib/i386-linux-gnu -levent' EVENT_CFLAGS='-I/usr/lib/i386-linux-gnu' EVENT_LIBS='-L/usr/lib/i386-linux-gnu -levent' CFLAGS='-I/usr/lib/i386-linux-gnu -levent -DBOOST_NO_CXX11_SCOPED_ENUMS -O1 -m32 -g -latomic -lboost_system -lboost_filesystem -levent_core -lgcc_s --rtlib=compiler-rt' CXXFLAGS='-I/usr/lib/i386-linux-gnu -levent -DBOOST_NO_CXX11_SCOPED_ENUMS -O1 -m32 -g -latomic -lboost_system -lboost_filesystem -levent_core -lgcc_s --rtlib=compiler-rt' ./configure --enable-static --disable-hardening --enable-util-cli --enable-util-tx --enable-util-wallet --with-libmultiprocess=no --with-incompatible-bdb --with-boost-libdir=/usr/lib/i386-linux-gnu
这是错误
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-init.o): in function `directory_iterator':
/usr/local/include/boost/filesystem/directory.hpp:278: undefined reference to `boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, unsigned int, boost::system::error_code*)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-init.o): in function `boost::filesystem::directory_entry::status() const':
/usr/local/include/boost/filesystem/directory.hpp:132: undefined reference to `boost::filesystem::directory_entry::get_status(boost::system::error_code*) const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-blockchain.o): in function `boost::filesystem::absolute(boost::filesystem::path const&, boost::filesystem::path const&)':
/usr/local/include/boost/filesystem/operations.hpp:258: undefined reference to `boost::filesystem::detail::absolute(boost::filesystem::path const&, boost::filesystem::path const&, boost::system::error_code*)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-torcontrol.o): in function `StartTorControl(CService)':
/home/blank/bitcoin-0.21.0/src/torcontrol.cpp:753: undefined reference to `evthread_use_pthreads'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-httpserver.o): in function `InitHTTPServer()':
/home/blank/bitcoin-0.21.0/src/httpserver.cpp:376: undefined reference to `evthread_use_pthreads'
/usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-walletutil.o): in function `recursive_directory_iterator':
/usr/local/include/boost/filesystem/directory.hpp:456: undefined reference to `boost::filesystem::detail::recursive_directory_iterator_construct(boost::filesystem::recursive_directory_iterator&, boost::filesystem::path const&, unsigned int, boost::system::error_code*)'
/usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-walletutil.o): in function `boost::filesystem::directory_entry::symlink_status() const':
/usr/local/include/boost/filesystem/directory.hpp:134: undefined reference to `boost::filesystem::directory_entry::get_symlink_status(boost::system::error_code*) const'
/usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-walletutil.o): in function `boost::filesystem::recursive_directory_iterator::increment(boost::system::error_code&)':
/usr/local/include/boost/filesystem/directory.hpp:500: undefined reference to `boost::filesystem::detail::recursive_directory_iterator_increment(boost::filesystem::recursive_directory_iterator&, boost::system::error_code*)'
/usr/bin/ld: libbitcoin_wallet.a(libbitcoin_wallet_a-bdb.o): in function `boost::filesystem::copy_file(boost::filesystem::path const&, boost::filesystem::path const&, boost::filesystem::copy_option::enum_type)':
/usr/local/include/boost/filesystem/operations.hpp:355: undefined reference to `boost::filesystem::detail::copy_file(boost::filesystem::path const&, boost::filesystem::path const&, unsigned int, boost::system::error_code*)'
我正在尝试在 Ubuntu 20.04 上编译该软件的 32 位版本。我做了一些研究,当库不适合正确的架构时,可能会出现这个问题。我仔细检查并安装了 i386 标签下的所有库。我该如何解决这个问题?
答:
0赞
sehe
2/15/2021
#1
让我们让它远程可读:
export EVENT_PTHREADS_CFLAGS='-I/usr/lib/i386-linux-gnu'
export EVENT_PTHREADS_LIBS='-L/usr/lib/i386-linux-gnu -levent'
export EVENT_CFLAGS='-I/usr/lib/i386-linux-gnu'
export EVENT_LIBS='-L/usr/lib/i386-linux-gnu;-levent'
export CFLAGS='-I/usr/lib/i386-linux-gnu
-DBOOST_NO_CXX11_SCOPED_ENUMS
-O1 -m32 -g -latomic
-levent -lboost_system -lboost_filesystem -levent_core -lgcc_s --rtlib=compiler-rt'
export CXXFLAGS='-I/usr/lib/i386-linux-gnu
-DBOOST_NO_CXX11_SCOPED_ENUMS
-O1 -m32 -g -latomic
-levent -lboost_system -lboost_filesystem -levent_core -lgcc_s --rtlib=compiler-rt'
./configure \
--enable-static \
--disable-hardening \
--enable-util-cli \
--enable-util-tx \
--enable-util-wallet \
--with-libmultiprocess=no \
--with-incompatible-bdb \
--with-boost-libdir=/usr/lib/i386-linux-gnu
我确实注意到
export EVENT_LIBS='-L/usr/lib/i386-linux-gnu;-levent'
似乎很奇怪的语法。根据我的快速扫描,只是在命令行中被替换。不分隔选项(它充其量是分隔链接目录)。相反,使用空格来增加它执行预期操作的风险:${EVENT_LIBS}
;
export EVENT_LIBS='-L/usr/lib/i386-linux-gnu -levent'
当然,将 -L 标志添加到 LDFLAGS 会更有意义。添加到 / 的所有选项也是如此。我不确定 bitcoin-core 是否遵守所有 automake 约定,但我希望分为 , , CXXFLAGSLDFLAGS':-l*
CXXFLAGS
CFLAGS
CPPFLAGS
CFLAGS
and
export EVENT_PTHREADS_CFLAGS='-pthread'
export EVENT_CFLAGS='-I/usr/lib/i386-linux-gnu'
export EVENT_LIBS='-L/usr/lib/i386-linux-gnu -levent'
export CPPFLAGS='-I/usr/lib/i386-linux-gnu
-DBOOST_NO_CXX11_SCOPED_ENUMS
-O1 -m32 -g
--rtlib=compiler-rt'
export LDFLAGS='-latomic -levent -levent_core
-lboost_system -lboost_filesystem
-lgcc_s'
./configure \
--enable-static \
--disable-hardening \
--enable-util-cli \
--enable-util-tx \
--enable-util-wallet \
--with-libmultiprocess=no \
--with-incompatible-bdb \
--with-boost-libdir=/usr/lib/i386-linux-gnu
免責聲明我没有试过这个。
评论
0赞
Lepu Tenty
2/15/2021
感谢您的所有提示,我现在将尝试并让您知道
0赞
Lepu Tenty
2/15/2021
ld.lld: error: undefined symbol: boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, unsigned int, boost::system::error_code*) >>> referenced by directory.hpp:278 (/usr/local/include/boost/filesystem/directory.hpp:278) >>> lto.tmp:(boost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&, boost::filesystem::directory_options))
0赞
sehe
2/15/2021
Boost Filesystem 似乎没有链接。要么是这样,要么是著名的链接器选项顺序问题。您是否将旗帜移至 ?也许也应该在 LDFLAGS 中,只是意识到。-lXYZ
LDFLAGS
-L/usr/lib/i386-linux-gnu
0赞
Lepu Tenty
2/15/2021
让我试一试,我会让你知道的。
评论