Opened 11 years ago

Closed 11 years ago

#43650 closed defect (invalid)

boost::regex link error

Reported by: casmyu@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.2.1
Keywords: Cc: ryandesign (Ryan Carsten Schmidt)
Port:

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Hi there,

I installed boost with MacPorts, most library works perfectly except boost::regex. Here is the informations from my dev environment:

$ uname -a
Darwin Kernel Version 13.1.0: Wed Apr  2 23:52:02 PDT 2014; root:xnu-2422.92.1~2/RELEASE_X86_64 x86_64 
$ sudo port installed | grep boost
boost @1.55.0_2+no_single+no_static+python27 (active)

here is the source code, quite simple:

$ cat test.cpp

#include <sstream>
#include <iostream>

#include <boost/regex.hpp>

int main (int argc, const char* argv[])
{
    boost::regex exp("*");
    boost::regex_match("foo", exp);
}
$ g++ --version
g++ (MacPorts gcc48 4.8.2_0) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.

$ g++ -std=c++11 -o test -I/opt/local/include -L/opt/local/lib -lboost_regex-mt test.cpp
Undefined symbols for architecture x86_64:
  "boost::re_detail::perl_matcher<char const*, std::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)", referenced from:
      boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher(char const*, char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, char const*) in ccRUN4it.o
  "boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match()", referenced from:
      bool boost::regex_match<char const*, std::allocator<boost::sub_match<char const*> >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags) in ccRUN4it.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

Would you please help to check this problem? If you need any more information, please let me know.

Thank you!

Change History (2)

comment:1 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)

comment:2 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added
Resolution: invalid
Status: newclosed

Remember to use WikiFormatting when writing in Trac.

You cannot mix C++ runtimes. On OS X 10.9 Mavericks and later, the system runtime is libc++, and that is what boost and most other MacPorts ports are using as well. gcc uses libstdc++. They are not compatible. Compile your code with clang instead of gcc. See wiki:FAQ#libcpp.

Note: See TracTickets for help on using tickets.