Trying to build muParser: error: explicit instanti

2019-06-22 19:32发布

Im trying to build muParser on the mac, it worked until I upgraded XCode to 4.4 which updated gcc. Now I get the following line of code generating the error which I don't understand:

mu::console() << _T(" \"") << val.GetAsString() << _T("\" ");

../muparser/src/muParserBase.cpp:1823:   instantiated from here
../muparser/src/muParserBase.cpp:1823: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../muparser/src/muParserBase.cpp: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../muparser/src/muParserBase.cpp:1823:   instantiated from here
../muparser/src/muParserBase.cpp:1823: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../muparser/src/muParserBase.cpp: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../muparser/src/muParserBase.cpp:1823:   instantiated from here
../muparser/src/muParserBase.cpp:1823: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../muparser/src/muParserBase.cpp: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../muparser/src/muParserBase.cpp:1823:   instantiated from here
../muparser/src/muParserBase.cpp:1823: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available

mu::console() is define as:

inline std::ostream& console()
{
  return std::cout;
}

_T is #define _T(x) x

and GetAsString

  const TString& GetAsString() const
  {
    return m_strTok;
  }

TString is a std::string

It is the call to GetAsString that causes the problem. Any idea how to fix it?

3条回答
我想做一个坏孩纸
2楼-- · 2019-06-22 19:39

Add these two lines to your .pro file and the error will go away:

QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.7
QMAKE_CXXFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64
查看更多
神经病院院长
3楼-- · 2019-06-22 19:39

It looks like you are linking the wrong standard library or including the wrong C++ includes. You will want to make sure your include path c++ headers matches the standard library you are linking.

If you post your build file, I can help see if there is a mismatch.

查看更多
等我变得足够好
4楼-- · 2019-06-22 19:56

When I upgraded to XCode 4.4.x, the Command Line Tools were removed. In XCode, I wend to XCode > Preferences, selected the Downloads tab, and re-downloaded "Command Line Tools" and then things started to work again. Maybe this will fix your problem too?

查看更多
登录 后发表回答