fstream.h 中的 STL 命名空间错误与 qmake/make.
STL Namespace Errors in fstream.h with qmake/make
我正在尝试以老派的方式编译我的 QT5 项目,使用qmake && make
. 但是,我遇到了意外错误。 有~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
以下是生成的生成文件的可能部分
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 版本漂浮?
这个问题并不直观。 在一个不相关的标头中,gui.h
,我没有用结尾大括号关闭我的命名空间gui
。 我通过注释掉#include <fstream>
和编译来解决这个问题。 现在它工作正常。
相关文章:
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- qmake:检测目标位宽(32 位或 64 位)
- 使用 make 编译 MPI,几个命名空间错误,例如"错误:未知类型名称'使用'?
- make 命令如何避免重新编译未更改的源文件?
- MAKE:找不到包含的用户定义的头文件?
- 'make check' GLIBC 运行时的链接问题
- Qt5 [make -snap] 无法正确编译:进程"/usr/bin/snap"代码 1 退出
- mingw32-make 使用"MinGW Makefiles"生成器跟踪 CMAKE 无法将可执行文件链接到对象库
- 使用静态 qmake 的 QT Widget 插件
- make 命令创建 .file,但不创建应用程序文件
- 如何摆脱导入的 make 项目中的 Eclipse 索引器"Type std::... could not be resolved"错误
- CLion and Qt5: tuning qmake
- Qt Creator 在执行步骤 "make" 时出现编译错误,-fno-stack-limit
- 如何使用MySQL Connector and Make设置C++项目
- 使用 make 将对象文件放在特定目录中
- Qmake 错误:QT: 图表中的未知模块
- 我是 C++ 的新手,我试图调用 make 一个以 2 个类作为其参数的类构造函数
- fstream.h 中的 STL 命名空间错误与 qmake/make.
- 如何创建一个qmake函数来创建一个自定义的make目标
- Qmake 和 Make 在错误的目录中