Linking with Qt and Boost under MacOS X

Discussion in 'Mac Programming' started by shuras, Nov 18, 2015.

  1. shuras macrumors newbie

    Joined:
    Nov 18, 2015
    #1
    Hi there!
    I am quite a newbie on Mac platform and trying to port my code working under Windows and Linux to Yosemite.
    I use QtCreator (with Clang) as an IDE and Boost from brew for regex operations. Everything compile fine but linking produce errors for symbols like this:
    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)

    I checked contents of Boost library and didn't see any symbols with __normal_iterator in place.
    Looks like brew's Boost compiled with _wrap_iter instead of __normal_iterator.
    I suspect what it is just a matter of different compilers or C++ specs used but doesn't know much about MacOS environment. My system's g++ currently linked to Clang. I suppose it is possible to use GNU compiler instead and different possibility for std lib too.
    Can anyone recommend a way out from this situation? Any clue?
     
  2. cyrilleImage macrumors newbie

    Joined:
    Sep 17, 2010
    Location:
    Germany
    #2
    Qt and boost are nice framework and easy to use under mac.
    qmake is also an easy way to generate from a qt project (.pro) a Makefile or a Xcode project.

    the standard gcc/g++ from Apple development tools (4.2.1!!!) is very old. It was a release from 2007... Lots of modern things are missing such as c++11.

    Either you compile a new gcc/g++ or you use clang with c++11.

    The easiest is to recompile boost like that:
    ./bootstrap.sh --prefix=/usr/local
    sudo ./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++" -j 12 --prefix=/usr/local --build-dir=/Volumes/Develop/BuildMac/boost_1_59_0 release install

    then compile you project in the ide of your choose with clang and stdlib=libc++ and std=c++11

    Done.
     
  3. shuras thread starter macrumors newbie

    Joined:
    Nov 18, 2015
    #3
    Thank you for your answer.
    CXXFLAGS="-std=c++11 -stdlib=libc++"
    This is all I've been needed inside my qt project.
     

Share This Page