我已经使用 QtCreator 导入了一个现有项目。现在它在抱怨 "No rule to make target 'all'."

I've imported an existing project with QtCreator. Now it's complaining "No rule to make target 'all'."

我正在将一个 Windows/OS X 项目迁移到 Linux,我决定使用 Qt Creator 3.5.0 作为我的开发环境。我使用 "New File or Project > Import Project > Import Existing Project" 导入了现有的 C++ 文件,但是当我尝试构建时出现错误

"No rule to make target 'all'. Stop.".

四处寻找答案告诉我 Qt Creator 不应该为以这种方式导入的项目使用 makefile(Qt Creator manual 建议 .includes .files 和 .config 文件执行相同的功能) , 而编写我自己的 makefile 似乎不是正确的选择。如果导入甚至没有为我生成 makefile(如果确实有必要使用一个),我假设我的配置有问题。

除了编写自己的 makefile 之外,我不确定如何继续,在这种情况下,Qt Creator 导入工具似乎充其量也没有用。

当您想将 Qt Creator 用作代码编辑器时,可以使用导入现有项目功能。这来自您链接的手册:

Generic project support allows you to use Qt Creator as a code editor. You can change the way your project is built by modifying the make command in the Projects mode under Build Settings.

并且来自手册中的 this 页:

Import Existing Project

Import an existing project that does not use any of the supported build systems: qmake, Qbs, CMake, or Autotools. This enables you to use Qt Creator as a code editor

所以使用这种方法,Qt Creator不会为你生成makefile。有关如何使用此功能的示例,请参阅此 post:

Use qtcreator with makefile project

如果您想使用 Qt Creator 构建系统,您可以创建一个“普通 C++ 项目”,然后添加您的源文件。