QtCreator build system is broken after OSX upgrade

2019-06-20 11:32发布

问题:

I recently upgraded my OSX to mountain lion and ever since I cannot compile my project using Qt Creator anymore. I get bunch of errors like the following:

/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;

gridName is a std::ostringstream object and xdmfName_ is a std::string variable declared as a private member of the xdmfWriter class and initialized in the class constructor. I did not have this problem before ... Any ideas?

回答1:

This can be fixed by adding a c_str() as in:

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

However, this is not a permanent solution.

Update: I found the solution in https://web.archive.org/web/20140809210004/http://qt-project.org/forums/viewthread/19106/P15

You need to change -mmacosx-version-min=10.5 in $QTDIR/mkspecs/common/g++-macx.conf to -mmacosx-version-min=10.7. This is because SDKs for 10.5 or 10.6 are not included in Mountain Lion and XCode 4.4.



回答2:

I have tried changing the g++-macx.conf fila but I was still getting the errors. I found that using:

QMAKE_CXXFLAGS += -fpermissive

on my pro file did the trick.



回答3:

Sounds like if I use the Clang toolchain (which forces clang++ instead of llvm-g++) I do not have this problem ...