链接提振正则表达式中的gcc [英] linking to boost regex in gcc

查看:128
本文介绍了链接提振正则表达式中的gcc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译我的程序,它在Linux上使用正则表达式。我建立了Boost库中
    林达/正则表达式/编译
通过键入
    使-fgcc.mak
这创建了包含以下四个文件的目录的gcc

i am trying to compile my program which uses regex on linux. I built the boost library in the libs/regex/build by typing make -fgcc.mak which created a directory gcc which contains the following four files

boost_regex-gcc-1_35
boost_regex-gcc-d-1_35
libboost_regex-gcc-1_35.a
libboost_regex-gcc-d-1_35.a

现在我想用正则表达式从我的计划,是在一些任意目录。
我执行#included提升/ regex.hpp

Now I want to use regex from my program which is in some arbitrary directory. I #included boost/regex.hpp

我得到了其中指出,regex.hpp没有发现错误。然后,我给在G ++编译器-I选项。我没有得到这个错误。
但我得到以下错误

I got the error which stated that regex.hpp is not found. Then I gave the -I option in the g++ compiler. I didn't get that error. But I get the following error

undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'

我用Google搜索,发现我需要以某种方式连接上述4库之一,我的程序。我怎样才能做到这一点。我应该链接,为什么哪一个?

I googled and found that I need to somehow link one of the above 4 libraries to my program. How can I do it. Which one should I link and why?

推荐答案

无论是添加 libboost_regex-GCC-1_35.a 到对象文件列表中的链接步骤或添加 -static -lboost_regex-GCC-1_35 来一样。另外要确保你有一个 -I 开关指向您的提升,包括在你的编译步骤目录。如果库是典型的搜索路径( / usr / lib目录在* nix)之外,该目录添加到您的链接命令轮候册, - L /路径/要/升压/库 G ++ 或只是 -L /路径/要/升压/库 LD

Either add libboost_regex-gcc-1_35.a to your list of object files in your link step or add -static -lboost_regex-gcc-1_35 to the same. Also be sure that you have an -I switch pointing to your boost includes directory in your compile step. If the libraries are outside the typical search path (/usr/lib on *nix), add that directory to your link command with -Wl,-L/path/to/boost/libs for g++ or simply -L/path/to/boost/libs on ld.

这篇关于链接提振正则表达式中的gcc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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