使用REGEX库构建VC ++代码时链接器错误 [英] Linker errors while building VC++ code with REGEX library

查看:112
本文介绍了使用REGEX库构建VC ++代码时链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试执行以下程序。它构建正常,但是我遇到了2个链接器错误:

请帮助我。

 # include   <   iostream  >  
#include < iterator >
#include < regex >
#include < string > ;
// #define BOOST_REGEX_DYN_LINK

使用 命名空间性病;

int main()
{
std :: string text = 快速棕狐;
std :: regex vowel_re1( a | e | i | o | u) ;


// 将结果写入输出迭代器
std :: regex_replace(std :: ostreambuf_iterator< char>(std :: cout),
text.begin(),text.end(),vowel_re1, *);

// 构造一个包含结果的字符串
std: :cout<< ' \ n'<< std :: regex_replace(text,vowel_re1, [$&])<< ' \ n';
}



链接器错误:

 myClient.obj:错误LNK2019:未解析的外部符号class std :: basic_string< char,struct> ;, class std :: allocator< char>> __cdecl std :: tr1 :: regex_replace< class>,char,struct std :: char_traits< char> ,class std :: allocator< char>>(class std :: basic_string< char,struct>,class std :: allocator< char>> const&,class std :: tr1 :: basic_regex< char,class> > const&,char const *,enum std :: tr1 :: regex_constants :: match_flag_type)(?? $ regex_replace @ V?$ regex_traits @ D @ tr1 @ std @@ DU?$ char_traits @ D @ 3 @ V'$分配器@ d @ @@ 3 TR1 @ @@ STD YA?AV?$ basic_string的@ DU?$ char_traits @ d @ @@ STD V'$分配器@ d @ @@ 2 1 @ ABV21 @ ABV?$ basic_regex @DV?$ regex_traits @ D @ tr1 @ std @@@ 01 @ PBDW4match_flag_type @ regex_constants @ 01 @@ Z)在函数_main 
1> myClient.obj中引用:错误LNK2019:未解析的外部符号class std :: ostreambuf_iterator< char,struct>> __cdecl std :: tr1 :: regex_replace< cl屁股> >,类std :: _ St​​ring_iterator< char,struct>,类std :: allocator< char> >,类std :: tr1 :: regex_traits< char>,char>(类std :: ostreambuf_iterator< char,struct>>,类std :: _ St​​ring_iterator< char,struct> ;, class std :: allocator< char> >,类std :: _ St​​ring_iterator< char,struct>,类std :: allocator< char>>,类std :: tr1 :: basic_regex< char,class>> const&,char const *,enum std :: tr1 :: regex_constants :: match_flag_type)(?? $ regex_replace @ V?$ ostreambuf_iterator @ DU?$ char_traits @ D @ std @@@ std @@ V?$ _ St​​ring_iterator @ DU?$ char_traits @ D @ std @ @V?$分配器@ d @ @@ 2 2 @ V'$ regex_traits @ d @ TR1 @ 2 @ d @ TR1 @ @@ STD YA?AV?$ ostreambuf_iterator @ DU?$ char_traits @ d @ STD @@@ 1 @ V21 @ V'$ _ St​​ring_iterator @ DU?$ char_traits @ d @ @@ STD V'$分配器@ d @ @@ 2 1 @ 1ABV?$ basic_regex @ DV?$ regex_traits @ d @ TR1 @ STD @@@ 01 @ PBDW4match_flag_type @ regex_constants @ 01 @@ Z)在函数_main
1> C:\ Users \ smallesh \Documents\Visual Studio 2010 \Projects \C#\ Client \Debug \Client中引用.exe:致命错误LNK1120:2个未解析的外部

解决方案

&])<< ' \ n';
}



链接器错误:

 myClient.obj:错误LNK2019:未解析的外部符号class std :: basic_string< char,struct> ;, class std :: allocator< char>> __cdecl std :: tr1 :: regex_replace< class>,char,struct std :: char_traits< char> ,class std :: allocator< char>>(class std :: basic_string< char,struct>,class std :: allocator< char>> const&,class std :: tr1 :: basic_regex< char,class> > const&,char const *,enum std :: tr1 :: regex_constants :: match_flag_type)(?? 


regex_replace @ V?


< BLOCKQUOTE> regex_traits @ d @ TR1 @ @@ STD DU?

Hi,

I am trying to execute below program. It is building fine but am getting 2 linker errors:
Kindly help me.

#include <iostream>
#include <iterator>
#include <regex>
#include <string>
//#define BOOST_REGEX_DYN_LINK

using namespace std;
 
int main()
{
   std::string text = "Quick brown fox";
   std::regex vowel_re1("a|e|i|o|u");

 
   // write the results to an output iterator
   std::regex_replace(std::ostreambuf_iterator<char>(std::cout),
                      text.begin(), text.end(), vowel_re1, "*");
 
   // construct a string holding the results
   std::cout << '\n' << std::regex_replace(text, vowel_re1, "[$&]") << '\n';
}


Linker errors:

myClient.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct>,class std::allocator<char> > __cdecl std::tr1::regex_replace<class>,char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct>,class std::allocator<char> > const &,class std::tr1::basic_regex<char,class> > const &,char const *,enum std::tr1::regex_constants::match_flag_type)" (??$regex_replace@V?$regex_traits@D@tr1@std@@DU?$char_traits@D@3@V?$allocator@D@3@@tr1@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@ABV21@ABV?$basic_regex@DV?$regex_traits@D@tr1@std@@@01@PBDW4match_flag_type@regex_constants@01@@Z) referenced in function _main
1>myClient.obj : error LNK2019: unresolved external symbol "class std::ostreambuf_iterator<char,struct> > __cdecl std::tr1::regex_replace<class> >,class std::_String_iterator<char,struct>,class std::allocator<char> >,class std::tr1::regex_traits<char>,char>(class std::ostreambuf_iterator<char,struct> >,class std::_String_iterator<char,struct>,class std::allocator<char> >,class std::_String_iterator<char,struct>,class std::allocator<char> >,class std::tr1::basic_regex<char,class> > const &,char const *,enum std::tr1::regex_constants::match_flag_type)" (??$regex_replace@V?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@V?$regex_traits@D@tr1@2@D@tr1@std@@YA?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@1@V21@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@1@1ABV?$basic_regex@DV?$regex_traits@D@tr1@std@@@01@PBDW4match_flag_type@regex_constants@01@@Z) referenced in function _main
1>C:\Users\smallesh\Documents\Visual Studio 2010\Projects\C#\Client\Debug\Client.exe : fatal error LNK1120: 2 unresolved externals

解决方案

&]") << '\n'; }


Linker errors:

myClient.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct>,class std::allocator<char> > __cdecl std::tr1::regex_replace<class>,char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct>,class std::allocator<char> > const &,class std::tr1::basic_regex<char,class> > const &,char const *,enum std::tr1::regex_constants::match_flag_type)" (??


regex_replace@V?


regex_traits@D@tr1@std@@DU?


这篇关于使用REGEX库构建VC ++代码时链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆