So I've just started off with Google's OpenFST toolkit and I'm trying out their examples. Using C++ on Eclipse Mars and upon build I get the following error:
fatal error: 'type_traits' file not found
Here's my sample program - when I'm trying from here.
#include <iostream>
#include <fst/fst-decl.h>
#include <fst/fstlib.h>
using namespace std;
int main() {
fst::StdVectorFst fst;
return 0;
}
And when I build it, I get the following errors:
/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
Is there some linker error? Why is it unable to find that header file? It does exist in the /usr/include/c++/4.2.1/tr1/ directory on my computer. What am I doing wrong?
looks like a C compiler, trying to compile a C++ file
// test.h
#include <type_traits>
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
the file type_traits is provided by package libstdc++,
see debian package search
related: clang throws error file not found when a cppheader.h file is wrapped in a wrapper.hpp file
# 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
I counted for this problem,solved it in this way: xxx.c->xxx.cpp all in all, you should compile it in g++, not gcc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With