gpt4 book ai didi

c++ - boost 正则表达式链接 : Can't find library

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:44:51 25 4
gpt4 key购买 nike

我在链接 Boost Regex 时遇到问题,尽管我可以运行(编译/链接)其他 Boost 程序。

我意识到这是“有据可查的”,但我找不到答案,因为各种帖子使用不同版本的 Boost、不同的编译器、使用 bjam(我使用 b2),似乎暗示了我已经尝试过的东西等。

设置

  • Visual Studio 10(我使用的是 C++)

  • boost 版本:1.53.0

  • 初始安装:我关注了How to use Boost in Visual Studio 2010 (我走到了第二点4)。我没有下载正则表达式的 ICU 支持,因为我认为只有在需要 Unicode 支持时才需要它?

  • 我已通过更新“包含目录”并添加 C:......\Boost\boost_1_53_0 将相关库包含在项目属性中

  • 我通过添加“C:.....\Boost\boost_1_53_0\stage\lib”将相关目录包含在项目属性库目录中,以便它知道库的链接位置(位于至少我认为这是这样做的)。

问题

我可以使用(例如)Boost 随机数编译、链接和运行程序。

如果我尝试通过以下方式添加 Regex 功能:

boost::algorithm::split_regex( result, str, regex( "[0-9]+|->" ) )

我收到以下形式的链接错误。

1>Bibtex.obj : error LNK2001: unresolved external symbol "private: class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > & __thiscall boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::do_assign(char const *,char const *,unsigned int)" (?do_assign@?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@AAEAAV12@PBD0I@Z)
1>Bibtex.obj : error LNK2001: unresolved external symbol "public: bool __thiscall boost::re_detail::perl_matcher<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<struct boost::sub_match<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> > > >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::find(void)" (?find@?$perl_matcher@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail@boost@@QAE_NXZ)
1>Bibtex.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::re_detail::perl_matcher<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<struct boost::sub_match<class std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> > > >,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > >::construct_init(class boost::basic_regex<char,struct boost::regex_traits<char,class boost::w32_regex_traits<char> > > const &,enum boost::regex_constants::_match_flags)" (?construct_init@?$perl_matcher@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@U?$sub_match@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@boost@@@2@U?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@re_detail@boost@@AAEXABV?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@3@W4_match_flags@regex_constants@3@@Z)
1>C:\Users\kzzgrk\Dropbox\Projects\classes\Bibtex\BibtexFramework\Debug\BibtexFramework.exe : fatal error LNK1120: 3 unresolved externals

我不知道如何解决这个问题,因为我似乎已经尝试了所有方法。我能想到的唯一可能性是我需要使用 b2 命令行程序构建 boost 库,但我无法找到该命令应该是什么(正如我上面所说的,很多引用资料都是到 bjam)。

如有任何帮助/建议,我们将不胜感激。

最佳答案

我发现了一个可能的原因,可以帮助一些人。基本上,我已经为 64 位 构建了 Boost,但默认情况下我创建的应用程序是 32 位。这适用于大多数库,但不适用于 Regex 库,因此出现错误。将项目切换到 64 位,现在一切正常。

关于c++ - boost 正则表达式链接 : Can't find library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15997522/

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