Sat*_*ian 6 c++ eclipse-cdt type-traits openfst
所以我刚刚开始使用 Google 的 OpenFST 工具包,并且正在尝试他们的示例。在 Eclipse Mars 上使用 C++ 并在构建时出现以下错误:
fatal error: 'type_traits' file not found
这是我的示例程序 - 当我从这里尝试时。
#include <iostream>
#include <fst/fst-decl.h>
#include <fst/fstlib.h>
using namespace std;
int main() {
fst::StdVectorFst fst;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我构建它时,我收到以下错误:
/usr/local/include/fst/util.h:15:10: fatal error: 'type_traits' file not found
#include <type_traits>
^
1 error generated.
make: *** [src/sampleFST.o] Error 1
Run Code Online (Sandbox Code Playgroud)
是否存在链接器错误?为什么找不到那个头文件?它确实存在于/usr/include/c++/4.2.1/tr1/我的计算机上的目录中。我究竟做错了什么?
看起来像一个C编译器,试图编译一个C++文件
// test.h
#include <type_traits>
Run Code Online (Sandbox Code Playgroud)
clang -c test.h
# test.h:1:10: fatal error: 'type_traits' file not found
gcc -c test.h
# test.h:1:10: fatal error: type_traits: No such file or directory
# solutions ...
# fix file extension
gcc -c test.hh
clang -c test.hh
# set language in compiler flag
gcc -c -x c++ test.h
clang -c -x c++ test.h
# set language in compiler command
g++ -c in.h
clang++ -c in.h
Run Code Online (Sandbox Code Playgroud)
该文件type_traits由软件包提供libstdc++,请参阅debian 软件包搜索
file not found相关:当cppheader.h文件包装在wrapper.hpp文件中时, clang 会抛出错误
# cppheader.h has wrong file extension, should be hh/hpp/hxx
echo '#include <type_traits>' >cppheader.h
echo '#include "cppheader.h"' >wrapper.hpp
# error with clang
clang -c wrapper.hpp # -> fatal error: 'type_traits' file not found
# works with gcc
gcc -c wrapper.hpp
Run Code Online (Sandbox Code Playgroud)