clang を使用して Mac にブーストをインストールしました。
Include = /usr/local/include/boost-1_54/
Lib = /usr/local/lib/
( libboost_atomic-clang-darwin42-mt-1_54.a, libboost_math_c99f-clang-darwin42-mt-1_54.dylib)
次に、インストールが正しく行われたかどうかをテストしたいと思いました。boost::regex を使用する単純なコードをコンパイルしようとしています。
$$ clang++ -I /usr/local/include/boost-1_54/ -L /usr/local/lib/ -o regex test_regex.cpp
それは言うエラーを与える
Undefined symbols for architecture x86_64:
"boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)", referenced from:
boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int) in test_regex-qSWMLF.o
"boost::re_detail::get_mem_block()", referenced from:
boost::re_detail::perl_matcher<std::__1::__wrap_iter<char const*>, std::__1::allocator<boost::sub_match<std::__1::__wrap_iter<char const*> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::extend_stack() in test_regex-qSWMLF.o
boost::re_detail::save_state_init::save_state_init(boost::re_detail::saved_state**, boost::re_detail::saved_state**) in test_regex-qSWMLF.o
"boost::re_detail::put_mem_block(void*)", referenced from:
boost::re_detail::save_state_init::~save_state_init() in test_regex-qSWMLF.o
boost::re_detail::perl_matcher<std::__1::__wrap_iter<char const*>, std::__1::allocator<boost::sub_match<std::__1::__wrap_iter<char const*> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::unwind_extra_block(bool) in test_regex-qSWMLF.o
"boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)", referenced from:
boost::re_detail::perl_matcher<std::__1::__wrap_iter<char const*>, std::__1::allocator<boost::sub_match<std::__1::__wrap_iter<char const*> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_imp() in test_regex-qSWMLF.o
"boost::re_detail::raise_runtime_error(std::runtime_error const&)", referenced from:
void boost::re_detail::raise_error<boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > >(boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::error_type) in test_regex-qSWMLF.o
"boost::re_detail::get_default_error_string(boost::regex_constants::error_type)", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::error_string(boost::regex_constants::error_type) const in test_regex-qSWMLF.o
"boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const", referenced from:
boost::cpp_regex_traits<char>::transform_primary(char const*, char const*) const in test_regex-qSWMLF.o
"boost::re_detail::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const", referenced from:
boost::cpp_regex_traits<char>::transform(char const*, char const*) const in test_regex-qSWMLF.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gcc を使用して簡単なブースト プログラムをコンパイルするときに、-libregex などを使用したことを覚えています。すべての組み合わせを試しましたが、それでもエラーが発生します(つまり、-libboost_regex-mt、libboost_atomic-clang-darwin42-mt-1_54.a、..)
$$ clang++ -I /usr/local/include/boost-1_54/ -L /usr/local/lib/ -o regex test_regex.cpp -libboost_regex
ld: library not found for -libregex
テストを正しくコンパイルするために適切なライブラリ関数を使用するようにclangに指示するにはどうすればよいですか?