gpt4 book ai didi

c++ - 如何通过 autoconf/automake 对 boost 库/ header 包含进行故障排除?

转载 作者:搜寻专家 更新时间:2023-10-31 00:48:50 25 4
gpt4 key购买 nike

我是 autom4te 的新手,我正在尝试使用 autoconf/automake 在多个体系结构上构建和链接 C++ 程序。使链接复杂化的是项目需要 boost (文件系统、系统、程序选项)这一事实。

我正在使用 boost.m4(来自 http://github.com/tsuna/boost.m4/tree/ ),它似乎成功地找到了所有库和 header 。

不幸的是,链接仍然失败,让我很困惑。

这些是configure.ac的相关行:

AC_CONFIG_MACRO_DIR([m4])
# ...
AC_PROG_CXX
AC_PROG_LIBTOOL
# ...
BOOST_REQUIRE([1.41.0])
BOOST_FILESYSTEM
BOOST_SYSTEM
BOOST_PROGRAM_OPTIONS
# ...

src/Makefile.am 中:

bin_PROGRAMS = phenomatrix
phenomatrix_CXXFLAGS = $(BOOST_CPPFLAGS)
phenomatrix_LDFLAGS = $(BOOST_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_FILESYSTEM_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LDFLAGS) # $(BOOST_SYSTEM_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB)
phenomatrix_LIBS = $(BOOST_SYSTEM_LIBS) $(BOOST_FILESYSTEM_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS)
phenomatrix_SOURCES = adjacency_list.cpp distance.cpp genephene.cpp knearest.cpp marshall.cpp oracle.cpp type_shield.cpp avgmindist.cpp euclidean.cpp hypergeometric.cpp main.cpp mindist.cpp partialbayes.cpp utilities.cpp

这些没有错误,它甚至设法找到库和 header :

checking for Boost headers version >= 104100... yes
checking for Boost's header version... 1_41
checking for the toolset name used by Boost for g++... gcc44 -gcc
checking boost/system/error_code.hpp usability... yes
checking boost/system/error_code.hpp presence... yes
checking for boost/system/error_code.hpp... yes
checking for the Boost system library... yes
checking boost/filesystem/path.hpp usability... yes
checking boost/filesystem/path.hpp presence... yes
checking for boost/filesystem/path.hpp... yes
checking for the Boost filesystem library... yes
checking for boost/system/error_code.hpp... (cached) yes
checking for the Boost system library... (cached) yes
checking boost/program_options.hpp usability... yes
checking boost/program_options.hpp presence... yes
checking for boost/program_options.hpp... yes
checking for the Boost program_options library... yes

但是,当我运行 make 时,出现错误:

libtool: link: g++ -g -O2 -o phenomatrix phenomatrix-adjacency_list.o phenomatrix-distance.o phenomatrix-genephene.o phenomatrix-knearest.o phenomatrix-marshall.o phenomatrix-oracle.o phenomatrix-type_shield.o phenomatrix-avgmindist.o phenomatrix-euclidean.o phenomatrix-hypergeometric.o phenomatrix-main.o phenomatrix-mindist.o phenomatrix-partialbayes.o phenomatrix-utilities.o  -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib
phenomatrix-adjacency_list.o: In function `__static_initialization_and_destruction_0':
/usr/local/include/boost/system/error_code.hpp:208: undefined reference to `boost::system::get_system_category()'
/usr/local/include/boost/system/error_code.hpp:209: undefined reference to `boost::system::get_generic_category()'
/usr/local/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::get_generic_category()'
/usr/local/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::get_generic_category()'
/usr/local/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::get_system_category()'

重复广告令人作呕。

我什至不确定如何进行测试以查看它是否包含正确的目录。是的,我知道 g++ 上有一个 -t 标志,但我不知道如何传递它(从 autom4te 内部)。

我认为这与同一台机器上的多个版本的 boost 库和 header 有关,对此我无能为力。

最佳答案

它没有编译,因为它的库没有正确设置...脚本没有正确配置 -lboost_libraryname 选项。

$(BOOST_PROGRAM_OPTIONS_LIB) -> $(BOOST_PROGRAM_OPTIONS_LIBS) in tyour makefil.am your_program_LDFLAGS

以下存储库中的 ax_boost_***.m4 脚本对我来说运行良好:

关于c++ - 如何通过 autoconf/automake 对 boost 库/ header 包含进行故障排除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2270073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com