5

我试图在 mac 上构建 muParser,直到我将 XCode 升级到更新 gcc 的 4.4 之前它一直有效。现在我得到以下代码行,生成我不明白的错误:

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()定义为:

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

_T#define _T(x) x

GetAsString

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

TString是一个std::string

导致问题的是对 GetAsString 的调用。知道如何解决吗?

4

3 回答 3

9

将这两行添加到您的 .pro 文件中,错误就会消失:

QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.7
QMAKE_CXXFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64
于 2012-08-26T20:10:06.027 回答
0

当我升级到 XCode 4.4.x 时,命令行工具被删除了。在 XCode 中,我转到 XCode > Preferences,选择下载选项卡,然后重新下载“命令行工具”,然后事情又开始工作了。也许这也能解决你的问题?

于 2012-08-28T22:58:52.007 回答
0

看起来您正在链接错误的标准库或包含错误的 C++ 包含。您需要确保您的包含路径 c++ 标头与您链接的标准库相匹配。

如果您发布构建文件,我可以帮助查看是否存在不匹配。

于 2012-07-31T21:13:19.880 回答