QtCreator构建系统在OSX升级后损坏

QtCreator build system is broken after OSX upgrade

本文关键字:损坏 OSX 构建 系统 QtCreator      更新时间:2023-10-16

我最近将我的OSX升级到了mountain lion,从那以后我就不能再使用Qt Creator编译我的项目了。我得到一堆错误如下:

/Users/user/codes/lib/io/xdmfWriter.cpp:63: 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

/Users/user/codes/lib/io/xdmfWriter.cpp:-1: 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>]':

/Users/user/codes/lib/io/xdmfWriter.cpp:63: instantiated from here

// xdmfWriter.cpp -- line 63:
gridName << xdmfName_ << "." << timeStep;

gridNamestd::ostringstream对象,xdmfName_是声明为xdmfWriter类的私有成员并在类构造函数中初始化的std::string变量。我以前没有这个问题。。。有什么想法吗?

这可以通过在中添加c_str()来修复

gridName << xdmfName_.c_str() << "." << timeStep;

然而,这并不是一个永久性的解决方案。

更新:我在中找到了解决方案https://web.archive.org/web/20140809210004/http://qt-project.org/forums/viewthread/11106/P15

您需要将$QTDIR/mkspecs/common/g++-macx.conf中的-mmacosx-version-min=10.5更改为-mmacosx-version-min=10.7。这是因为Mountain Lion和XCode 4.4中不包含10.5或10.6的SDK。

我已经尝试更改g++-macx.conf文件,但仍然出现错误。我发现使用:

QMAKE_CXXFLAGS += -fpermissive

在我的专业档案上做到了。

听起来如果我使用Clang工具链(强制使用clang++而不是llvm-g++),我就没有这个问题。。。