当前位置: 动力学知识库 > 问答 > 编程问答 >

c++ - Trying to build muParser: error: explicit instantiation of 'std::basic_ostream but no definition available

问题描述:

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?

网友答案:

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
网友答案:

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.

网友答案:

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?

分享给朋友:
您可能感兴趣的文章:
随机阅读: