Boost Log 1.54 on Mac OS and QtCreator (G++) - c++

How can one use logging library from Boost on version 1.54 ? (I'm using QtCreator and have successfully used boost/filesystem)
I read that the logging lib is now part of Boost, but I can't make it work on MacOs:
My .pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2013-10-30T14:34:26
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Fottopic
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
configwindow.cpp \
windowmanager.cpp
HEADERS += mainwindow.h \
configwindow.h \
windowmanager.h
INCLUDEPATH += /usr/local/Cellar/boost/1.54.0/include
QMAKE_LIBDIR += /usr/local/Cellar/boost/1.54.0/lib
LIBS += -lboost_system\
-lboost_filesystem\
-lboost_log\
-lboost_log_setup
Output when building:
Undefined symbols for architecture x86_64:
"boost::log::v2s_mt_posix::sinks::text_file_backend::~text_file_backend()", referenced from:
boost::detail::sp_ms_deleter<boost::log::v2s_mt_posix::sinks::text_file_backend>::destroy() in main.o
"boost::log::v2s_mt_posix::sinks::text_file_backend::construct(boost::filesystem::path const&, std::_Ios_Openmode, unsigned long, boost::log::v2s_mt_posix::aux::light_function<bool ()()> const&, bool)", referenced from:
void boost::log::v2s_mt_posix::sinks::text_file_backend::construct<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> const&)in main.o
"boost::log::v2s_mt_posix::sinks::text_file_backend::flush()", referenced from:
void boost::log::v2s_mt_posix::sinks::basic_sink_frontend::flush_backend_impl<boost::mutex, boost::log::v2s_mt_posix::sinks::text_file_backend>(boost::mutex&, boost::log::v2s_mt_posix::sinks::text_file_backend&, mpl_::bool_<true>)in main.o
"boost::detail::get_tss_data(void const*)", referenced from:
boost::thread_specific_ptr<boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::get() constin main.o
"boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)", referenced from:
boost::thread_specific_ptr<boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::reset(boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context*)in main.o
boost::thread_specific_ptr<boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::~thread_specific_ptr()in main.o
"boost::log::v2s_mt_posix::sinks::text_file_backend::consume(boost::log::v2s_mt_posix::record_view const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
void boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::log::v2s_mt_posix::aux::fake_mutex, boost::log::v2s_mt_posix::sinks::text_file_backend>(boost::log::v2s_mt_posix::record_view const&, boost::log::v2s_mt_posix::aux::fake_mutex&, boost::log::v2s_mt_posix::sinks::text_file_backend&)in main.o
void boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::mutex, boost::log::v2s_mt_posix::sinks::text_file_backend>(boost::log::v2s_mt_posix::record_view const&, boost::mutex&, boost::log::v2s_mt_posix::sinks::text_file_backend&)in main.o
"boost::log::v2s_mt_posix::aux::default_attribute_names::message()", referenced from:
boost::log::v2s_mt_posix::expressions::tag::message::get_name() in main.o
"boost::log::v2s_mt_posix::aux::code_convert(wchar_t const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::locale const&)", referenced from:
boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >& boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >::formatted_write<wchar_t>(wchar_t const*, long)in main.o
"boost::log::v2s_mt_posix::aux::once_block_sentry::enter_once_block() const", referenced from:
boost::log::v2s_mt_posix::aux::once_block_sentry::executed() constin main.o
"boost::log::v2s_mt_posix::aux::once_block_sentry::rollback()", referenced from:
boost::log::v2s_mt_posix::aux::once_block_sentry::~once_block_sentry()in main.o
"boost::log::v2s_mt_posix::aux::once_block_sentry::commit()", referenced from:
boost::array<std::pair<boost::log::v2s_mt_posix::type_info_wrapper, void*>, 2ul> const& boost::log::v2s_mt_posix::aux::type_sequence_dispatcher<boost::mpl::vector2<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > >::get_dispatching_map<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&> >()in main.o
"boost::log::v2s_mt_posix::attribute_value_set::find(boost::log::v2s_mt_posix::attribute_name) const", referenced from:
boost::log::v2s_mt_posix::visitation_result boost::log::v2s_mt_posix::value_visitor_invoker<boost::mpl::vector2<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, boost::log::v2s_mt_posix::fallback_to_none>::operator()<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&> >(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute_value_set const&, boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&>) constin main.o
"boost::log::v2s_mt_posix::attribute_value_set::end() const", referenced from:
boost::log::v2s_mt_posix::visitation_result boost::log::v2s_mt_posix::value_visitor_invoker<boost::mpl::vector2<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, boost::log::v2s_mt_posix::fallback_to_none>::operator()<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&> >(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute_value_set const&, boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&>) constin main.o
"boost::log::v2s_mt_posix::aux::attach_attribute_name_info(boost::exception&, boost::log::v2s_mt_posix::attribute_name const&)", referenced from:
boost::log::v2s_mt_posix::visitation_result boost::log::v2s_mt_posix::value_visitor_invoker<boost::mpl::vector2<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, boost::log::v2s_mt_posix::fallback_to_none>::operator()<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&> >(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute_value_set const&, boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::char_traits<char>, std::allocator<char> >&>) constin main.o
"boost::log::v2s_mt_posix::sinks::text_file_backend::set_file_collector(boost::shared_ptr<boost::log::v2s_mt_posix::sinks::file::collector> const&)", referenced from:
boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::aux::add_file_log<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> const&)in main.o
"boost::log::v2s_mt_posix::sinks::text_file_backend::scan_for_files(boost::log::v2s_mt_posix::sinks::file::scan_method, bool)", referenced from:
boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::aux::add_file_log<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> const&)in main.o
"boost::log::v2s_mt_posix::core::get()", referenced from:
boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::aux::add_file_log<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> const&)in main.o
"boost::log::v2s_mt_posix::core::add_sink(boost::shared_ptr<boost::log::v2s_mt_posix::sinks::sink> const&)", referenced from:
boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::aux::add_file_log<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, char const [11]> const&)in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [Fottopic.app/Contents/MacOS/Fottopic] Error 1
17:48:19: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Fottopic (kit: Desktop)
When executing step 'Make'

Related

Boost log linking error on OSX

I've been trying to compile the following example program from the boost tutorial to create a logger all morning and can't work out what I'm doing wrong:
#include <boost/log/common.hpp>
#include <boost/log/sinks.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/expressions.hpp>
#include <boost/core/null_deleter.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>
using namespace boost::log;
BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity", int)
int main()
{
typedef sinks::asynchronous_sink<sinks::text_ostream_backend> text_sink;
boost::shared_ptr<text_sink> sink = boost::make_shared<text_sink>();
boost::shared_ptr<std::ostream> stream{&std::clog,
boost::null_deleter{}};
sink->locked_backend()->add_stream(stream);
sink->set_filter(severity > 0);
sink->set_formatter(expressions::stream << severity << ": " <<
expressions::smessage);
core::get()->add_sink(sink);
sources::severity_logger<int> lg;
BOOST_LOG_SEV(lg, 0) << "note";
BOOST_LOG_SEV(lg, 1) << "warning";
BOOST_LOG_SEV(lg, 2) << "error";
sink->flush();
}
using the following commands:
clang -std=c++11 -c ./test.cpp -Wall -DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK -DBOOST_LOG_DYN_LINK
clang test.o -o test -DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK -DBOOST_LOG_DYN_LINK
And I'm met with a massive error message that ends like this:
vtable for boost::log::v2s_mt_posix::attribute::impl in test-7198fd.o
vtable for boost::detail::sp_counted_base in test-7198fd.o
vtable for boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char> in test-7198fd.o
vtable for boost::log::v2s_mt_posix::sinks::basic_sink_frontend in test-7198fd.o
vtable for boost::log::v2s_mt_posix::sinks::sink in test-7198fd.o
vtable for boost::detail::tss_cleanup_function in test-7198fd.o
...
"___cxa_rethrow", referenced from:
boost::detail::shared_count::shared_count<boost::log::v2s_mt_posix::sinks::asynchronous_sink<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2s_mt_posix::sinks::unbounded_fifo_queue>*, boost::detail::sp_ms_deleter<boost::log::v2s_mt_posix::sinks::asynchronous_sink<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2s_mt_posix::sinks::unbounded_fifo_queue> > >(boost::log::v2s_mt_posix::sinks::asynchronous_sink<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2s_mt_posix::sinks::unbounded_fifo_queue>*, boost::detail::sp_inplace_tag<boost::detail::sp_ms_deleter<boost::log::v2s_mt_posix::sinks::asynchronous_sink<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2s_mt_posix::sinks::unbounded_fifo_queue> > >) in test-7198fd.o
boost::log::v2s_mt_posix::sinks::basic_sink_frontend::will_consume(boost::log::v2s_mt_posix::attribute_value_set const&) in test-7198fd.o
boost::log::v2s_mt_posix::visitation_result boost::log::v2s_mt_posix::value_visitor_invoker<boost::mpl::vector2<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, boost::log::v2s_mt_posix::fallback_to_none>::operator()<boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::expressions::aux::stream_ref<boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&> >(boost::log::v2s_mt_posix::attribute_name const&, boost::log::v2s_mt_posix::attribute_value_set const&, boost::log::v2s_mt_posix::binder1st<boost::log::v2s_mt_posix::output_fun, boost::log::v2s_mt_posix::expressions::aux::stream_ref<boost::log::v2s_mt_posix::basic_formatting_ostream<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>) const in test-7198fd.o
boost::detail::shared_count::shared_count<boost::thread_specific_ptr<boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::delete_data*, boost::detail::do_heap_delete<boost::thread_specific_ptr<boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::delete_data> >(boost::thread_specific_ptr<boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::delete_data*, boost::detail::do_heap_delete<boost::thread_specific_ptr<boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::delete_data>) in test-7198fd.o
boost::log::v2s_mt_posix::aux::threadsafe_queue<boost::log::v2s_mt_posix::record_view, std::__1::allocator<void> >::threadsafe_queue(std::__1::allocator<boost::log::v2s_mt_posix::aux::threadsafe_queue_types<boost::log::v2s_mt_posix::record_view, std::__1::allocator<void> >::node> const&) in test-7198fd.o
boost::detail::shared_count::shared_count<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>*, boost::detail::sp_ms_deleter<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> > >(boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>*, boost::detail::sp_inplace_tag<boost::detail::sp_ms_deleter<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> > >) in test-7198fd.o
void boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::feed_record<boost::recursive_mutex, boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char> >(boost::log::v2s_mt_posix::record_view const&, boost::recursive_mutex&, boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>&) in test-7198fd.o
...
"___cxa_throw", referenced from:
boost::log::v2s_mt_posix::aux::threadsafe_queue<boost::log::v2s_mt_posix::record_view, std::__1::allocator<void> >::threadsafe_queue(std::__1::allocator<boost::log::v2s_mt_posix::aux::threadsafe_queue_types<boost::log::v2s_mt_posix::record_view, std::__1::allocator<void> >::node> const&) in test-7198fd.o
void boost::throw_exception<boost::thread_resource_error>(boost::thread_resource_error const&) in test-7198fd.o
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::thread_resource_error> >::rethrow() const in test-7198fd.o
void boost::throw_exception<boost::lock_error>(boost::lock_error const&) in test-7198fd.o
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >::rethrow() const in test-7198fd.o
void boost::throw_exception<boost::condition_error>(boost::condition_error const&) in test-7198fd.o
boost::detail::interruption_checker::check_for_interruption() in test-7198fd.o
...
"___gxx_personality_v0", referenced from:
_main in test-7198fd.o
boost::system::system_error::what() const in test-7198fd.o
boost::detail::sp_if_not_array<boost::log::v2s_mt_posix::sinks::asynchronous_sink<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2s_mt_posix::sinks::unbounded_fifo_queue> >::type boost::make_shared<boost::log::v2s_mt_posix::sinks::asynchronous_sink<boost::log::v2s_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2s_mt_posix::sinks::unbounded_fifo_queue> >() in test-7198fd.o
void boost::log::v2s_mt_posix::sinks::basic_sink_frontend::set_filter<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::greater, boost::proto::argsns_::list2<boost::log::v2s_mt_posix::expressions::attribute_actor<int, boost::log::v2s_mt_posix::fallback_to_none, tag::severity, boost::phoenix::actor>, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<int>, 0l> > >, 2l> > >(boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::greater, boost::proto::argsns_::list2<boost::log::v2s_mt_posix::expressions::attribute_actor<int, boost::log::v2s_mt_posix::fallback_to_none, tag::severity, boost::phoenix::actor>, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<int>, 0l> > >, 2l> > const&) in test-7198fd.o
void boost::log::v2s_mt_posix::sinks::basic_formatting_sink_frontend<char>::set_formatter<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<2> >, 0l> >, boost::log::v2s_mt_posix::expressions::attribute_actor<int, boost::log::v2s_mt_posix::fallback_to_none, tag::severity, boost::phoenix::actor> >, 2l> >, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<char [3]>, 0l> > >, 2l> >, boost::log::v2s_mt_posix::expressions::attribute_actor<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::log::v2s_mt_posix::fallback_to_none, boost::log::v2s_mt_posix::expressions::tag::smessage, boost::phoenix::actor> >, 2l> > >(boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<2> >, 0l> >, boost::log::v2s_mt_posix::expressions::attribute_actor<int, boost::log::v2s_mt_posix::fallback_to_none, tag::severity, boost::phoenix::actor> >, 2l> >, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<char [3]>, 0l> > >, 2l> >, boost::log::v2s_mt_posix::expressions::attribute_actor<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::log::v2s_mt_posix::fallback_to_none, boost::log::v2s_mt_posix::expressions::tag::smessage, boost::phoenix::actor> >, 2l> > const&) in test-7198fd.o
boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger<int> >::stream() const in test-7198fd.o
boost::detail::shared_count::~shared_count() in test-7198fd.o
...
ld: symbol(s) not found for architecture x86_64
Boost was installed using:
brew install boost --c++11
Any ideas what's going on?
UPDATE
Having accidentally tried to compile the code in C as pointed out by gavinb, I've tried to recompile using the correct c++ compiler:
c++ -std=c++11 -c ./test.cpp -Wall -DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK -DBOOST_LOG_DYN_LINK
c++ test.o -o test -DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK -DBOOST_LOG_DYN_LINK
and now receive the following error:
st::thread_specific_ptr<boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::get() const in test.o
"boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)", referenced from:
boost::thread_specific_ptr<boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::reset(boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context*) in test.o
boost::thread_specific_ptr<boost::log::v2_mt_posix::sinks::basic_formatting_sink_frontend<char>::formatting_context>::~thread_specific_ptr() in test.o
"boost::detail::thread_data_base::~thread_data_base()", referenced from:
boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf0<void, boost::log::v2_mt_posix::sinks::asynchronous_sink<boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2_mt_posix::sinks::unbounded_fifo_queue> >, boost::_bi::list1<boost::_bi::value<boost::log::v2_mt_posix::sinks::asynchronous_sink<boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2_mt_posix::sinks::unbounded_fifo_queue>*> > > >::~thread_data() in test.o
"boost::detail::get_current_thread_data()", referenced from:
boost::detail::interruption_checker::interruption_checker(_opaque_pthread_mutex_t*, _opaque_pthread_cond_t*) in test.o
"boost::system::system_category()", referenced from:
___cxx_global_var_init2 in test.o
boost::thread_exception::thread_exception(int, char const*) in test.o
boost::condition_error::condition_error(int, char const*) in test.o
"boost::system::generic_category()", referenced from:
___cxx_global_var_init in test.o
___cxx_global_var_init1 in test.o
"boost::thread::join_noexcept()", referenced from:
boost::thread::join() in test.o
"boost::thread::native_handle()", referenced from:
boost::thread::get_id() const in test.o
"boost::thread::start_thread_noexcept()", referenced from:
boost::thread::start_thread() in test.o
"boost::thread::detach()", referenced from:
boost::thread::~thread() in test.o
"boost::thread::thread()", referenced from:
boost::log::v2_mt_posix::sinks::asynchronous_sink<boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2_mt_posix::sinks::unbounded_fifo_queue>::asynchronous_sink(bool) in test.o
"boost::log::v2_mt_posix::attribute_value_set::end() const", referenced from:
boost::log::v2_mt_posix::visitation_result boost::log::v2_mt_posix::value_visitor_invoker<boost::mpl::vector2<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, boost::log::v2_mt_posix::fallback_to_none>::operator()<boost::log::v2_mt_posix::binder1st<boost::log::v2_mt_posix::output_fun, boost::log::v2_mt_posix::expressions::aux::stream_ref<boost::log::v2_mt_posix::basic_formatting_ostream<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&> >(boost::log::v2_mt_posix::attribute_name const&, boost::log::v2_mt_posix::attribute_value_set const&, boost::log::v2_mt_posix::binder1st<boost::log::v2_mt_posix::output_fun, boost::log::v2_mt_posix::expressions::aux::stream_ref<boost::log::v2_mt_posix::basic_formatting_ostream<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>) const in test.o
boost::log::v2_mt_posix::value_extractor<int, boost::log::v2_mt_posix::fallback_to_none, tag::severity>::operator()(boost::log::v2_mt_posix::attribute_name const&, boost::log::v2_mt_posix::attribute_value_set const&) const in test.o
boost::log::v2_mt_posix::value_extractor<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::log::v2_mt_posix::fallback_to_none, boost::log::v2_mt_posix::expressions::tag::smessage>::operator()(boost::log::v2_mt_posix::attribute_name const&, boost::log::v2_mt_posix::attribute_value_set const&) const in test.o
"boost::log::v2_mt_posix::attribute_value_set::find(boost::log::v2_mt_posix::attribute_name) const", referenced from:
boost::log::v2_mt_posix::visitation_result boost::log::v2_mt_posix::value_visitor_invoker<boost::mpl::vector2<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, boost::log::v2_mt_posix::fallback_to_none>::operator()<boost::log::v2_mt_posix::binder1st<boost::log::v2_mt_posix::output_fun, boost::log::v2_mt_posix::expressions::aux::stream_ref<boost::log::v2_mt_posix::basic_formatting_ostream<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&> >(boost::log::v2_mt_posix::attribute_name const&, boost::log::v2_mt_posix::attribute_value_set const&, boost::log::v2_mt_posix::binder1st<boost::log::v2_mt_posix::output_fun, boost::log::v2_mt_posix::expressions::aux::stream_ref<boost::log::v2_mt_posix::basic_formatting_ostream<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>) const in test.o
boost::log::v2_mt_posix::value_extractor<int, boost::log::v2_mt_posix::fallback_to_none, tag::severity>::operator()(boost::log::v2_mt_posix::attribute_name const&, boost::log::v2_mt_posix::attribute_value_set const&) const in test.o
boost::log::v2_mt_posix::value_extractor<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::log::v2_mt_posix::fallback_to_none, boost::log::v2_mt_posix::expressions::tag::smessage>::operator()(boost::log::v2_mt_posix::attribute_name const&, boost::log::v2_mt_posix::attribute_value_set const&) const in test.o
"boost::log::v2_mt_posix::aux::once_block_sentry::enter_once_block() const", referenced from:
boost::log::v2_mt_posix::aux::once_block_sentry::executed() const in test.o
"boost::log::v2_mt_posix::core::get_logging_enabled() const", referenced from:
boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_composite_logger<char, boost::log::v2_mt_posix::sources::severity_logger<int>, boost::log::v2_mt_posix::sources::single_thread_model, boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<int> > >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, int const> >(boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, int const> const&) in test.o
"boost::thread::joinable() const", referenced from:
boost::log::v2_mt_posix::sinks::asynchronous_sink<boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2_mt_posix::sinks::unbounded_fifo_queue>::flush() in test.o
boost::log::v2_mt_posix::sinks::asynchronous_sink<boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2_mt_posix::sinks::unbounded_fifo_queue>::stop() in test.o
"typeinfo for boost::detail::thread_data_base", referenced from:
typeinfo for boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf0<void, boost::log::v2_mt_posix::sinks::asynchronous_sink<boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2_mt_posix::sinks::unbounded_fifo_queue> >, boost::_bi::list1<boost::_bi::value<boost::log::v2_mt_posix::sinks::asynchronous_sink<boost::log::v2_mt_posix::sinks::basic_text_ostream_backend<char>, boost::log::v2_mt_posix::sinks::unbounded_fifo_queue>*> > > > in test.o
"vtable for boost::detail::thread_data_base", referenced from:
boost::detail::thread_data_base::thread_data_base() in test.o
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
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Finally found a command that solved the problem:
clang++ -std=c++11 -DBOOST_LOG_DYN_LINK ./test.cpp -o test -lboost_log-mt -lpthread -lboost_thread-mt -lboost_system-mt
These symbols belong to the C++ runtime:
___cxa_throw
___gxx_personality_v0
When the linker complains these are missing, it is because you are linking the app as a C app rather than a C++ app.
Rather than invoking clang, just use c++ for both compiling and linking and it should work.
Some Boost libraries are header-only (being heavily templated), which means the implementation is completely provided by headers and thus does not require linking a separate library. But some Boost libraries (check the documentation as this is specifically noted) require linking a .so or .dylib for the implementation. This requires specifying the library name with the -l flag, such as -lboost_thread-mt and possibly the -L flag if the libraries aren't on your library path.
In your case, both the threading and logging libraries need their own libraries added to the link stage, and these also depend on the system library (a common/shared library). As you discovered, this means adding the following to the link phase:
-lpthread -lboost_log-mt -lboost_thread-mt -lboost_system-mt

boost regex built failed on MacOX

On Linux machine, my code could build successfully.
However, on my Mac, the same command cannot build unless I take out this part:
void split_is(const std::string &s, string delim_regex, std::vector<std::string> &elems) {
// Terribly slow and inefficient, sorry. Should probably fix this at some point
boost::algorithm::split_regex(elems, s, regex(delim_regex));
std::vector<std::string> non_zero_elems;
for(int e = 0; e < elems.size(); e++){
if (elems[e].length() > 0){
non_zero_elems.push_back(elems[e]);
}
}
elems = non_zero_elems; }
The command I used is:
g++ -lboost_regex -lgurobi_c++ -lgurobi60 -stdlib=libstdc++ -lpthread
-lm -Wall -m64 -fPIE -fexceptions -frounding-math -O2 -I/Library/gurobi604/mac64/include/ -I/usr/local/include/ -L/Library/gurobi604/mac64/lib/ -L/usr/local/lib/ main.cpp tools.cpp treeofdevil.cpp solver.cpp periodicfunction.cpp -o ising.exe /usr/local/lib/libboost_regex.a
Does anyone know what might possibly go wrong? Thank you.
The error I get is:
Undefined symbols for architecture x86_64:
"boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > > const&)", referenced from:
boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_prefix() in tools-9bd02e.o
boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_match() in tools-9bd02e.o
"boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, 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::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, 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::string>) in tools-9bd02e.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
unsigned int boost::re_detail::find_sort_syntax<boost::re_detail::cpp_regex_traits_implementation<char>, char>(boost::re_detail::cpp_regex_traits_implementation<char> const*, char*) in libboost_regex.a(instances.o)
char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(char const*, char const*, boost::re_detail::re_set_long<unsigned int> const*, boost::re_detail::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, bool) in libboost_regex.a(instances.o)
char* boost::re_detail::re_is_set_member<char*, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(char*, char*, boost::re_detail::re_set_long<unsigned int> const*, boost::re_detail::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, bool) in libboost_regex.a(instances.o)
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
void std::__1::vector<boost::re_detail::recursion_info<boost::match_results<char const*, std::__1::allocator<boost::sub_match<char const*> > > >, std::__1::allocator<boost::re_detail::recursion_info<boost::match_results<char const*, std::__1::allocator<boost::sub_match<char const*> > > > > >::__push_back_slow_path<boost::re_detail::recursion_info<boost::match_results<char const*, std::__1::allocator<boost::sub_match<char const*> > > > const>(boost::re_detail::recursion_info<boost::match_results<char const*, std::__1::allocator<boost::sub_match<char const*> > > > const&) in libboost_regex.a(instances.o)
std::__1::vector<boost::sub_match<char const*>, std::__1::allocator<boost::sub_match<char const*> > >::vector(std::__1::vector<boost::sub_match<char const*>, std::__1::allocator<boost::sub_match<char const*> > > const&) in libboost_regex.a(instances.o)
std::__1::vector<boost::sub_match<char const*>, std::__1::allocator<boost::sub_match<char const*> > >::insert(std::__1::__wrap_iter<boost::sub_match<char const*> const*>, unsigned long, boost::sub_match<char const*> const&) in libboost_regex.a(instances.o)
std::__1::enable_if<(__is_forward_iterator<boost::sub_match<char const*>*>::value) && (is_constructible<boost::sub_match<char const*>, std::__1::iterator_traits<boost::sub_match<char const*>*>::reference>::value), void>::type std::__1::vector<boost::sub_match<char const*>, std::__1::allocator<boost::sub_match<char const*> > >::assign<boost::sub_match<char const*>*>(boost::sub_match<char const*>*, boost::sub_match<char const*>*) in libboost_regex.a(instances.o)
std::__1::vector<bool, std::__1::allocator<bool> >::assign(unsigned long, bool const&) in libboost_regex.a(instances.o)
std::__1::vector<bool, std::__1::allocator<bool> >::reserve(unsigned long) in libboost_regex.a(instances.o)
void std::__1::vector<std::__1::pair<bool, boost::re_detail::re_syntax_base*>, std::__1::allocator<std::__1::pair<bool, boost::re_detail::re_syntax_base*> > >::__push_back_slow_path<std::__1::pair<bool, boost::re_detail::re_syntax_base*> const>(std::__1::pair<bool, boost::re_detail::re_syntax_base*> const&) in libboost_regex.a(instances.o)
...
"std::__1::__vector_base_common<true>::__throw_out_of_range() const", referenced from:
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_open_paren() in libboost_regex.a(instances.o)
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_perl_extension() in libboost_regex.a(instances.o)
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_collatename(char const*, char const*) const in libboost_regex.a(instances.o)
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_classname_imp(char const*, char const*) const in libboost_regex.a(instances.o)
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail(boost::regex_constants::error_type, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, long) in libboost_regex.a(instances.o)
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_classname(char const*, char const*) const in libboost_regex.a(instances.o)
"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
boost::re_detail::cpp_regex_traits_base<char>::imbue(std::__1::locale const&) in libboost_regex.a(instances.o)
boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const in libboost_regex.a(instances.o)
boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const> boost::re_detail::create_cpp_regex_traits<char>(std::__1::locale const&) in libboost_regex.a(instances.o)
"std::__1::ios_base::getloc() const", referenced from:
boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const in libboost_regex.a(instances.o)
"std::logic_error::logic_error(char const*)", referenced from:
boost::match_results<char const*, std::__1::allocator<boost::sub_match<char const*> > >::raise_logic_error() in libboost_regex.a(instances.o)
"std::logic_error::logic_error(char const*)", referenced from:
boost::re_detail::perl_matcher<char const*, std::__1::allocator<boost::sub_match<char const*> >, 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) in libboost_regex.a(instances.o)
"std::logic_error::logic_error(std::logic_error const&)", referenced from:
void boost::throw_exception<std::invalid_argument>(std::invalid_argument const&) in libboost_regex.a(instances.o)
void boost::throw_exception<std::logic_error>(std::logic_error const&) in libboost_regex.a(instances.o)
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::logic_error> >::rethrow() const in libboost_regex.a(instances.o)
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::logic_error> >::clone_impl(boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::logic_error> > const&, boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::logic_error> >::clone_tag) in libboost_regex.a(instances.o)
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::logic_error> >::clone_impl(boost::exception_detail::error_info_injector<std::logic_error> const&) in libboost_regex.a(instances.o)
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::invalid_argument> >::rethrow() const in libboost_regex.a(instances.o)
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::invalid_argument> >::clone_impl(boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::invalid_argument> > const&, boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::invalid_argument> >::clone_tag) in libboost_regex.a(instances.o)
...
"std::runtime_error::runtime_error(char const*)", referenced from:
boost::object_cache<boost::re_detail::cpp_regex_traits_base<char>, boost::re_detail::cpp_regex_traits_implementation<char> >::get(boost::re_detail::cpp_regex_traits_base<char> const&, unsigned long) in libboost_regex.a(instances.o)
"std::runtime_error::runtime_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > 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::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const in libboost_regex.a(instances.o)
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_collatename(char const*, char const*) const in libboost_regex.a(instances.o)
boost::re_detail::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::append_set(boost::re_detail::basic_char_set<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, mpl_::bool_<false>*) in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*)", referenced from:
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail(boost::regex_constants::error_type, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, long) in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)", referenced from:
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail(boost::regex_constants::error_type, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, long) in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(unsigned long, char)", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::assign(char const*, unsigned long)", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::assign(unsigned long, char)", referenced from:
char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(char const*, char const*, boost::re_detail::re_set_long<unsigned int> const*, boost::re_detail::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, bool) in libboost_regex.a(instances.o)
char* boost::re_detail::re_is_set_member<char*, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(char*, char*, boost::re_detail::re_set_long<unsigned int> const*, boost::re_detail::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, bool) in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::insert(std::__1::__wrap_iter<char const*>, char)", referenced from:
boost::re_detail::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::append_set(boost::re_detail::basic_char_set<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, mpl_::bool_<false>*) in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::reserve(unsigned long)", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__grow_by(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const in libboost_regex.a(instances.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::lookup_collatename(char const*, char const*) const in libboost_regex.a(instances.o)
boost::cpp_regex_traits<char>::catalog_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libboost_regex.a(instances.o)
boost::cpp_regex_traits<char>::get_catalog_name() in libboost_regex.a(instances.o)
boost::re_detail::cpp_regex_traits_implementation<char>::error_string(boost::regex_constants::error_type) const in libboost_regex.a(instances.o)
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse(char const*, char const*, unsigned int) in libboost_regex.a(instances.o)
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::fail(boost::regex_constants::error_type, long) in libboost_regex.a(instances.o)
boost::re_detail::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_extended() in libboost_regex.a(instances.o)
...
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const in libboost_regex.a(instances.o)
boost::re_detail::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const in libboost_regex.a(instances.o)
.....const in libboost_regex.a(instances.o)
boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::imbue(std::__1::locale) in libboost_regex.a(instances.o)
boost::cpp_regex_traits<char>::imbue(std::__1::locale) in libboost_regex.a(instances.o)
boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const> boost::re_detail::create_cpp_regex_traits<char>(std::__1::locale const&) in libboost_regex.a(instances.o)
boost::object_cache<boost::re_detail::cpp_regex_traits_base<char>, boost::re_detail::cpp_regex_traits_implementation<char> >::do_get(boost::re_detail::cpp_regex_traits_base<char> const&, unsigned long) in libboost_regex.a(instances.o)
unsigned long std::__1::__tree<std::__1::__value_type<boost::re_detail::cpp_regex_traits_base<char>, std::__1::__list_iterator<std::__1::pair<boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const>, boost::re_detail::cpp_regex_traits_base<char> const*>, void*> >, std::__1::__map_value_compare<boost::re_detail::cpp_regex_traits_base<char>, std::__1::__value_type<boost::re_detail::cpp_regex_traits_base<char>, std::__1::__list_iterator<std::__1::pair<boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const>, boost::re_detail::cpp_regex_traits_base<char> const*>, void*> >, std::__1::less<boost::re_detail::cpp_regex_traits_base<char> >, true>, std::__1::allocator<std::__1::__value_type<boost::re_detail::cpp_regex_traits_base<char>, std::__1::__list_iterator<std::__1::pair<boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const>, boost::re_detail::cpp_regex_traits_base<char> const*>, void*> > > >::__erase_unique<boost::re_detail::cpp_regex_traits_base<char> >(boost::re_detail::cpp_regex_traits_base<char> const&) in libboost_regex.a(instances.o)
...
"std::__1::locale::operator=(std::__1::locale const&)", referenced from:
boost::re_detail::cpp_regex_traits_base<char>::imbue(std::__1::locale const&) in libboost_regex.a(instances.o)
boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const> boost::re_detail::create_cpp_regex_traits<char>(std::__1::locale const&) in libboost_regex.a(instances.o)
"std::__1::collate<char>::id", referenced from:
boost::re_detail::cpp_regex_traits_base<char>::imbue(std::__1::locale const&) in libboost_regex.a(instances.o)
boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const> boost::re_detail::create_cpp_regex_traits<char>(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::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::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.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I suspect that you have more than one thing going on here; moving -lboost_regex should solve some of them.
I suspect that the main problem you have is that you've built part of your program (the boost libraries, probably) with libc++, and the rest with libstdc++.
Your build command explicitly says -stdlib=libstdc++, but the error message mentions std::__1::...., which is where things live in libc++.

Compiling a cpp file that uses Opencv

So I have a .cpp file that uses OpenCV. I've been having some problems with linking the libraries but I think my Makefile is "better" now.
Makefile:
CC=g++
#CC=gcc
# compile flags
CFLAGS=-g -Wall
# OpenCV Related
prefix=/usr/local/opencv
OCVFLAGS=-I${prefix}/include/opencv -I${prefix}/include
OCVLIBS=-L${prefix}/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_flann -lopencv_objdetect -lopencv_calib3d
PROGRAM=extractDescriptorsToFile
OBJECTS=$(PROGRAM).o
program: $(OBJECTS)
$(CC) $(OBJECTS) -o $(PROGRAM) $(OCVLIBS) -arch i386
$(PROGRAM).o: $(PROGRAM).cpp
$(CC) -c $(CFLAGS) $(OCVFLAGS) $(PROGRAM).cpp
clean:
rm -f *o
rm -f $(PROGRAM)
rm -f *~
However, when I "make", the .o file is generated but I get this error:
ld: warning: ignoring file extractDescriptorsToFile.o, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [program] Error 1
This is a similar post " Precompiled headers and compiling universal objects on OSX " but I don't think its quite my problem?
Any help would be appreciated...?
I think this error is sometimes cause by not having a main() but my file does...
Removing "-arch i386" leaves me with:
Undefined symbols for architecture x86_64:
"cv::operator<<(cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
cv::operator<<(cv::FileStorage&, char const*)in extractDescriptorsToFile.o
extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
_main in extractDescriptorsToFile.o
"cv::Ptr<CvFileStorage>::delete_obj()", referenced from:
cv::Ptr<CvFileStorage>::release() in extractDescriptorsToFile.o
"cv::fastFree(void*)", referenced from:
cv::Ptr<CvFileStorage>::release() in extractDescriptorsToFile.o
cv::Ptr<cv::FeatureDetector>::release() in extractDescriptorsToFile.o
cv::Ptr<cv::DescriptorExtractor>::release() in extractDescriptorsToFile.o
cv::Mat::~Mat() in extractDescriptorsToFile.o
"cv::fastMalloc(unsigned long)", referenced from:
cv::Ptr<cv::FeatureDetector>::Ptr(cv::FeatureDetector*)in extractDescriptorsToFile.o
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in extractDescriptorsToFile.o
"cv::Mat::copySize(cv::Mat const&)", referenced from:
cv::Mat::operator=(cv::Mat const&)in extractDescriptorsToFile.o
"cv::Exception::Exception(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)in extractDescriptorsToFile.o
"cv::error(cv::Exception const&)", referenced from:
cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)in extractDescriptorsToFile.o
"cv::Exception::~Exception()", referenced from:
cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)in extractDescriptorsToFile.o
"cv::write(cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&)", referenced from:
cv::FileStorage& cv::operator<< <cv::Mat>(cv::FileStorage&, cv::Mat const&)in extractDescriptorsToFile.o
"cv::_OutputArray::_OutputArray(cv::Mat&)", referenced from:
resizeImage(cv::Mat const&, int)in extractDescriptorsToFile.o
"cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
resizeImage(cv::Mat const&, int)in extractDescriptorsToFile.o
"cv::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int)", referenced from:
resizeImage(cv::Mat const&, int)in extractDescriptorsToFile.o
"cv::OrbFeatureDetector::OrbFeatureDetector(unsigned long, cv::ORB::CommonParams)", referenced from:
extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
"cv::FeatureDetector::create(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
"cv::DescriptorExtractor::create(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
"cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
"cv::FeatureDetector::detect(cv::Mat const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat const&) const", referenced from:
extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
"cv::DescriptorExtractor::compute(cv::Mat const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat&) const", referenced from:
extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
"cv::write(cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&)", referenced from:
extract(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, char**, cv::FileStorage&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in extractDescriptorsToFile.o
"cv::FileStorage::FileStorage()", referenced from:
_main in extractDescriptorsToFile.o
"cv::FileStorage::FileStorage(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
_main in extractDescriptorsToFile.o
"cv::FileStorage::~FileStorage()", referenced from:
_main in extractDescriptorsToFile.o
"cv::FileStorage::isOpened() const", referenced from:
_main in extractDescriptorsToFile.o
"cv::FileStorage::release()", referenced from:
_main in extractDescriptorsToFile.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [program] Error 1
This is what I get when I add -arch i386 to both program and $(PROGRAM).o:
Undefined symbols for architecture i386:
"_gzputs", referenced from:
icvPuts(CvFileStorage*, char const*)in libopencv_core.a(persistence.o)
"_gzgets", referenced from:
icvGets(CvFileStorage*, char*, int)in libopencv_core.a(persistence.o)
"_gzeof", referenced from:
icvEof(CvFileStorage*) in libopencv_core.a(persistence.o)
"_gzclose", referenced from:
_cvReleaseFileStorage in libopencv_core.a(persistence.o)
_cvOpenFileStorage in libopencv_core.a(persistence.o)
"_gzopen", referenced from:
_cvOpenFileStorage in libopencv_core.a(persistence.o)
"_gzrewind", referenced from:
_cvOpenFileStorage in libopencv_core.a(persistence.o)
"cv::Mat::convertTo(cv::Mat&, int, double, double) const", referenced from:
cv::imencode(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(loadsave.o)
cv::imwrite_(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&, std::vector<int, std::allocator<int> > const&, bool)in libopencv_highgui.a(loadsave.o)
"cv::flip(cv::Mat const&, cv::Mat&, int)", referenced from:
_cvEncodeImage in libopencv_highgui.a(loadsave.o)
cv::imwrite_(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&, std::vector<int, std::allocator<int> > const&, bool)in libopencv_highgui.a(loadsave.o)
"_jpeg_destroy_decompress", referenced from:
cv::JpegDecoder::close() in libopencv_highgui.a(grfmt_jpeg.o)
cv::JpegDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg.o)
cv::JpegDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg.o)
cv::JpegDecoder::~JpegDecoder()in libopencv_highgui.a(grfmt_jpeg.o)
cv::JpegDecoder::~JpegDecoder()in libopencv_highgui.a(grfmt_jpeg.o)
cv::JpegDecoder::~JpegDecoder()in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_CreateCompress", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_std_error", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
cv::JpegDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_destroy_compress", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_set_defaults", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_set_quality", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_start_compress", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_write_scanlines", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_finish_compress", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_stdio_dest", referenced from:
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_start_decompress", referenced from:
cv::JpegDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_read_scanlines", referenced from:
cv::JpegDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_finish_decompress", referenced from:
cv::JpegDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_alloc_huff_table", referenced from:
cv::JpegDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_CreateDecompress", referenced from:
cv::JpegDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_read_header", referenced from:
cv::JpegDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_stdio_src", referenced from:
cv::JpegDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg.o)
"_jpeg_resync_to_restart", referenced from:
cv::jpeg_buffer_src(jpeg_decompress_struct*, cv::JpegSource*) in libopencv_highgui.a(grfmt_jpeg.o)
cv::JpegDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg.o)
"_jas_init", referenced from:
__static_initialization_and_destruction_0(int, int)in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_cleanup", referenced from:
___tcf_0 in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_matrix_create", referenced from:
cv::Jpeg2KEncoder::writeComponent16u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KEncoder::writeComponent8u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_writecmpt", referenced from:
cv::Jpeg2KEncoder::writeComponent16u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KEncoder::writeComponent8u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_matrix_destroy", referenced from:
cv::Jpeg2KEncoder::writeComponent16u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KEncoder::writeComponent8u(void*, cv::Mat const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_stream_close", referenced from:
cv::Jpeg2KDecoder::close() in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_destroy", referenced from:
cv::Jpeg2KDecoder::close() in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_create", referenced from:
cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_stream_fopen", referenced from:
cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
cv::Jpeg2KDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_strtofmt", referenced from:
cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_encode", referenced from:
cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_getcmptbytype", referenced from:
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_cmprof_createfromclrspc", referenced from:
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_chclrspc", referenced from:
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_cmprof_destroy", referenced from:
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_readcmpt", referenced from:
cv::Jpeg2KDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_jpeg2000.o)
"_jas_image_decode", referenced from:
cv::Jpeg2KDecoder::readHeader() in libopencv_highgui.a(grfmt_jpeg2000.o)
"_png_destroy_read_struct", referenced from:
cv::PngDecoder::close() in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::readHeader() in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::~PngDecoder()in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::~PngDecoder()in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::~PngDecoder()in libopencv_highgui.a(grfmt_png.o)
"_png_create_write_struct", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_create_info_struct", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::readHeader() in libopencv_highgui.a(grfmt_png.o)
"_png_destroy_write_struct", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_set_write_fn", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_set_filter", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_set_compression_level", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_set_compression_strategy", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_set_IHDR", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_write_info", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_set_bgr", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_write_image", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_write_end", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_set_compression_mem_level", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
"_png_init_io", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::readHeader() in libopencv_highgui.a(grfmt_png.o)
"_png_set_swap", referenced from:
cv::PngEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)in libopencv_highgui.a(grfmt_png.o)
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_set_strip_alpha", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_read_update_info", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_read_image", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_read_end", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_set_rgb_to_gray", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_set_gray_to_rgb", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_set_expand_gray_1_2_4_to_8", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_set_palette_to_rgb", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_set_strip_16", referenced from:
cv::PngDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_png.o)
"_png_create_read_struct", referenced from:
cv::PngDecoder::readHeader() in libopencv_highgui.a(grfmt_png.o)
"_png_set_read_fn", referenced from:
cv::PngDecoder::readHeader() in libopencv_highgui.a(grfmt_png.o)
"_png_read_info", referenced from:
cv::PngDecoder::readHeader() in libopencv_highgui.a(grfmt_png.o)
"_png_get_IHDR", referenced from:
cv::PngDecoder::readHeader() in libopencv_highgui.a(grfmt_png.o)
"_png_error", referenced from:
cv::PngDecoder::readDataFromBuf(void*, unsigned char*, unsigned long)in libopencv_highgui.a(grfmt_png.o)
"_TIFFClose", referenced from:
cv::TiffDecoder::close() in libopencv_highgui.a(grfmt_tiff.o)
cv::TiffDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_tiff.o)
cv::TiffDecoder::readHeader() in libopencv_highgui.a(grfmt_tiff.o)
cv::TiffDecoder::~TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
cv::TiffDecoder::~TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
cv::TiffDecoder::~TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFIsTiled", referenced from:
cv::TiffDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFGetField", referenced from:
cv::TiffDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_tiff.o)
cv::TiffDecoder::readHeader() in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFReadEncodedStrip", referenced from:
cv::TiffDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFReadRGBAStrip", referenced from:
cv::TiffDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFReadEncodedTile", referenced from:
cv::TiffDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFReadRGBATile", referenced from:
cv::TiffDecoder::readData(cv::Mat&) in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFOpen", referenced from:
cv::TiffDecoder::readHeader() in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFRGBAImageOK", referenced from:
cv::TiffDecoder::readHeader() in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFSetErrorHandler", referenced from:
cv::TiffDecoder::TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
cv::TiffDecoder::TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
"_TIFFSetWarningHandler", referenced from:
cv::TiffDecoder::TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
cv::TiffDecoder::TiffDecoder()in libopencv_highgui.a(grfmt_tiff.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [program] Error 1
What happens if you remove explicit architecture specification (" -arch i386 ") from line 19? I guess that might help.
EDIT
Well it seems to me that you have a 64-bit OS, and 32-bit OpenCV libraries.

Boost serialization: Linking to libraries

I want to serialize objects in my program using the Boost library. It is my first time using it and it is giving me some problems.
In my program I have implemented the "serialize" method and include the following:
#include <fstream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
Now when I build I get the following errors:
Undefined symbols for architecture x86_64:
"boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)", referenced from:
boost::archive::text_oarchive::text_oarchive(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)in Main.o
"boost::archive::detail::basic_oarchive::~basic_oarchive()", referenced from:
boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()in Main.o
boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()in Main.o
boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()in Main.o
"boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()", referenced from:
boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()in Main.o
boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()in Main.o
boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()in Main.o
"vtable for boost::archive::archive_exception", referenced from:
boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)in Main.o
"typeinfo for boost::archive::archive_exception", referenced from:
void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)in Main.o
"boost::archive::archive_exception::~archive_exception()", referenced from:
void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<unsigned int>(unsigned int const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)in Main.o
...
"boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)", referenced from:
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<unsigned int>(unsigned int const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)in Main.o
"boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()", referenced from:
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<unsigned int>(unsigned int const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)in Main.o
"boost::archive::detail::basic_oarchive::end_preamble()", referenced from:
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::tracking_type>(boost::archive::text_oarchive&, boost::archive::tracking_type const&)in Main.o
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::object_reference_type>(boost::archive::text_oarchive&, boost::archive::object_reference_type const&)in Main.o
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::object_id_type>(boost::archive::text_oarchive&, boost::archive::object_id_type const&)in Main.o
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::version_type>(boost::archive::text_oarchive&, boost::archive::version_type const&)in Main.o
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(boost::archive::text_oarchive&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in Main.o
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::class_id_reference_type>(boost::archive::text_oarchive&, boost::archive::class_id_reference_type const&)in Main.o
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::class_id_type>(boost::archive::text_oarchive&, boost::archive::class_id_type const&)in Main.o
...
"boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(boost::archive::text_oarchive&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in Main.o
"typeinfo for boost::archive::detail::basic_oarchive", referenced from:
typeinfo for boost::archive::detail::common_oarchive<boost::archive::text_oarchive>in Main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [stable] Error 1
I am not sure if the problem is because of linking or if it has something to do with 64 bit and 32 bit architecture.
I have tried linking with:
-L/opt/local/lib/ -lboost_iostreams -lboost_serialization
But it does not seem to do any difference.
It looks like your boost library bundle is 32 bit only; you'll have to rebuild it adding 64 bit binaries, or set your main project to match the boost libraries.
Try setting your project to generate a 32 bit binary instead of 64 bit. In XCode 4.2, you'd use the Architecture section of the build settings in the project inspector.
In my case: It is because I used compiler gcc6 (or gcc5 has same issue). And my code used different compile flag with boost libraries. Detail explanation is in this link
If you can recompile all incompatible libs you use, do it with compiler option
-D_GLIBCXX_USE_CXX11_ABI=1
and then rebuild your project. If still can not link, add change project's makefile compiler option to 0.
-D_GLIBCXX_USE_CXX11_ABI=0

boost example failed to build

I'm a newbie about boost. I compiled boost libraries with success (under mac os x). Now, I tried to build the very first example mentioned at boost website (including boost/ as include directory and boost/stage/lib as library directory, with netbeans) and got the following error
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/boost_ex1
mkdir -p build/Debug/GNU-MacOSX
rm -f build/Debug/GNU-MacOSX/main.o.d
g++ -c -g -I../../boost_1_44_0 -MMD -MP -MF build/Debug/GNU-MacOSX/main.o.d -o build/Debug/GNU-MacOSX/main.o main.cpp
mkdir -p dist/Debug/GNU-MacOSX
g++ -o dist/Debug/GNU-MacOSX/boost_ex1 build/Debug/GNU-MacOSX/main.o -L../../boost_1_44_0/stage/lib
Undefined symbols:
"boost::re_detail::get_mem_block()", 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> > >::extend_stack()in main.o
"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> > > > > >::maybe_assign(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> > > > > > const&)", 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> > >::match_match()in main.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) constin main.o
boost::re_detail::cpp_regex_traits_implementation<char>::error_string(boost::regex_constants::error_type) constin main.o
"boost::re_detail::put_mem_block(void*)", 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> > >::unwind_extra_block(bool)in main.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 main.o
"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> > >::match()", referenced from:
bool boost::regex_match<__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> > > > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(__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)in main.o
"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 main.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*) constin main.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*) constin main.o
"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 main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-MacOSX/boost_ex1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
am I missing something?
Thanks!
Most Boost libraries are header-only:
they consist entirely of header files
containing templates and inline
functions, and require no
separately-compiled library binaries
or special treatment when linking.
However, the Boost.Regex library has a library you have to link with if you are using its code. For more details on this see Getting Started guide.
So the problem in your case is that you are not linking with Boost.Regex library, called libboost_regex.so. In order to do that, modify your project settings (or make file) so that it invokes gcc with -lboost_regex option. This option should come right after -L../../boost_1_44_0/stage/lib option that you already have, like this
g++ -o dist/Debug/GNU-MacOSX/boost_ex1 build/Debug/GNU-MacOSX/main.o -L../../boost_1_44_0/stage/lib -lboost_regex
Good luck!