I'm trying to compile my QT5 project the old school way, with qmake && make
. However, I'm getting unexpected errors. There are ~20, but here's a sampling (they're all similar):
In file included from src/main.cc:18:
In file included from include/Ctx.h:7:
In file included from include/SrcFile.h:5:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/fstream:268:9: error:
no template named 'has_facet'; did you mean
'::std::has_facet'?
if (has_facet<codecvt<char_type, char, state_...
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:177:1: note:
'::std::has_facet' declared here
has_facet(const locale& __l) _NOEXCEPT
^
In file included from src/main.cc:18:
In file included from include/Ctx.h:7:
In file included from include/SrcFile.h:5:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/fstream:268:19: error:
no template named 'codecvt'; did you mean
'::std::codecvt'?
if (has_facet<codecvt<char_type, char, state_...
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:817:86: note:
'::std::codecvt' declared here
...class _StateT> class _LIBCPP_TYPE_VIS_ONLY codecvt;
^
fatal error: too many errors emitted, stopping now
[-ferror-limit=]
20 errors generated.
make: *** [tmp/main.o] Error 1
Below is SrcFile.h
#ifndef SRCFILE_H
#define SRCFILE_H
#include <string>
#include <fstream>
#include "SrcObj.h"
namespace oonalysis {
class SrcFile : public SrcObj
{
public:
SrcFile(const std::string& filename);
std::string get_text() const;
std::string present_name() const;
private:
std::filebuf* get_file();
std::string filename;
}; // class SrcFile
} // namespace oonalysis
#endif // SRCFILE_H
And below are the likely segments of the generated Makefile
INCPATH = -I. -Iinclude -I/usr/local/Cellar/qt/5.9.1/lib/QtWidgets.fram
ework/Headers -I/usr/local/Cellar/qt/5.9.1/lib/QtGui.framework/Headers -I/usr
/local/Cellar/qt/5.9.1/lib/QtCore.framework/Headers -I. -I/Applications/Xcode
.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.
sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.
app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.s
dk/System/Library/Frameworks/AGL.framework/Headers -I/usr/local/Cellar/qt/5.9
.1/mkspecs/macx-clang -F/usr/local/Cellar/qt/5.9.1/lib
CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CXX = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
CXXFLAGS = -pipe -stdlib=libc++ -g -std=gnu++1y $(EXPORT_ARCH_ARGS) -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC $(DEFINES)
tmp/srcfile.o: src/srcfile.cc include/SrcFile.h \
include/SrcObj.h \
include/oonalysis.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tmp/srcfile.o src/srcfile.cc
Have I misconfigured something? Is there any way I could have two stl versions floating around?
The issue was not intuitive. In an unrelated header, gui.h
, I hadn't closed off my namespace gui
with an end brace. I figured this out by commenting out #include <fstream>
and compiling. Now it works fine.