致命错误:字符串:没有那个文件或目录

时间:2021-05-13 23:22:15

标签: c++ cmake g++

我在使用 cmake 编译时收到此消息:

In file included from scanner.lex:6:
C:\Users\uriya\CLionProjects\untitled1\output.hpp:4:10: fatal error: string: No such file or directory
    4 | #include <string>
      |          ^~~~~~~~
compilation terminated.
make.exe[3]: *** [CMakeFiles\untitled1.dir\build.make:88: CMakeFiles/untitled1.dir/lex.yy.c.obj] Error 1
make.exe[3]: *** Waiting for unfinished jobs....
make.exe[2]: *** [CMakeFiles\Makefile2:72: CMakeFiles/untitled1.dir/all] Error 2
make.exe[1]: *** [CMakeFiles\Makefile2:84: CMakeFiles/untitled1.dir/rule] Error 2
make.exe: *** [Makefile:117: untitled1] Error 2

这是导致问题的代码部分:

#ifndef _236360_2_
#define _236360_2_

#include <string>
using namespace std;

namespace output {
    extern const string rules[];
    void printProductionRule(int ruleno);
    void errorLex(int lineno);
    void errorSyn(int lineno);
};

#endif

这就是 cmake 的输入:

cmake_minimum_required(VERSION 3.13)
project(untitled1)

set(CMAKE_CXX_STANDARD 11)

add_executable(untitled1 parser.tab.cpp output.cpp lex.yy.c)

奇怪的是,我设法使用 g++ -std=c++11 -o hw2 parser.tab.cpp output.cpp lex.yy.c 毫无问题地编译它 cmake 和这个命令有什么区别?

0 个答案:

没有答案