我正在尝试使用qmake && make
以旧学校的方式编译我的QT5项目。但是,我遇到了意想不到的错误。有~20,但这里是一个抽样(它们都很相似):
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
下面是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
以下是生成的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
我错误配置了什么吗?有什么方法可以让两个stl版本浮动?
答案 0 :(得分:0)
问题不直观。在一个不相关的标头gui.h
中,我没有用结束括号关闭我的命名空间gui
。我通过评论#include <fstream>
和编译来解决这个问题。现在它工作正常。