オープンソースのソフトウェアで使用するためにMacOSでboostをインストールしようとしています。最初に私はこの例に従っていきたいと思っていました。ブーストの例Unix用スタートアップマニュアルが動作しない
私はまず、自作を使ってブースト(brew install boost
)をインストールします。
それから私はexample.cppコードこのコマンドを使用
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat("^Subject: (Re: |Aw:)*(.*)");
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
コンパイルしよう:c++ -I /usr/local/Cellar/boost/1.64.0_1/ example.cpp -o example /usr/local/Cellar/boost/1.64.0_1/lib/libboost_regex.a
そして、私は非常に長いエラーメッセージが出ます:
Undefined symbols for architecture x86_64:
"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)", referenced from:
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> > >::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::match_results<__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::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >) in ccCPUnqq.o
を... 返信 ...
"std::__1::locale::operator=(std::__1::locale const&)", referenced from:
boost::re_detail_106400::cpp_regex_traits_base<char>::imbue(std::__1::locale const&) in libboost_regex.a(instances.o)
"std::__1::collate<char>::id", referenced from:
boost::re_detail_106400::cpp_regex_traits_base<char>::imbue(std::__1::locale const&) in libboost_regex.a(instances.o)
"std::__1::ios_base::init(void*)", referenced from:
boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const in libboost_regex.a(instances.o)
"std::__1::ios_base::clear(unsigned int)", referenced from:
boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const in libboost_regex.a(instances.o)
"std::__1::messages<char>::id", referenced from:
boost::re_detail_106400::cpp_regex_traits_base<char>::imbue(std::__1::locale const&) in libboost_regex.a(instances.o)
"std::__1::numpunct<char>::id", referenced from:
boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const in libboost_regex.a(instances.o)
"std::__1::basic_ios<char, std::__1::char_traits<char> >::~basic_ios()", referenced from:
boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const in libboost_regex.a(instances.o)
"typeinfo for std::__1::basic_streambuf<char, std::__1::char_traits<char> >", referenced from:
typeinfo for boost::re_detail_106400::parser_buf<char, std::__1::char_traits<char> > in libboost_regex.a(instances.o)
"vtable for std::__1::basic_istream<char, std::__1::char_traits<char> >", referenced from:
boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const in libboost_regex.a(instances.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
私はこれに2日間を費やしており、私の人生にとっては私が間違っていることを理解できません。誰もが明白な何かを見たり、何か提案がありますか?私がインストールしようとしているオープンソースソフトウェアは、誰でもブーストでコンパイルしようとしている場合はhereです。 /opt/local/bin/g++
そして、私の$PATH
:
/usr/local/gcc/bin:/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/net/dnscrypt-proxy/Portfile:/Applications:/Applications:/Applications/sratoolkit.2.8.0-mac64/bin:/Applications/STAR/bin/MacOSX_x86_64:/Users/johngiorgi/.local/bin:/Users/johngiorgi/anaconda3/bin:/opt/local/bin:/opt/local/sbin:/Applications/ncbi-blast-2.4.0+/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/var/rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/boost/1.64.0_1/include:/usr/local/Cellar/boost/1.64.0_1/include/boost/tr1 :/opt/X11/bin:/usr/local/go/bin:/Library/TeX/texbin
感謝を。残念ながらXcode 8.3.2もインストールされており、書かれたコマンドは私の質問に投稿したのと同じエラーを返します。 –
'PATH'変数の内容を質問に加え、' which g ++ 'の結果を追加できますか? –
これを追加しました。 –