Qt 可执行文件在 Cmake 项目中不存在

Qt executable does not exist in Cmake project

我在 Ubuntu 14.04 下的 Qt5.2.1 中打开了一个 cmake 项目。 在project->build->CMake arguments: -DCMAKE_BUILD_TYPE:=Debug

在我成功构建项目并尝试 运行 之后,我在应用程序输出中收到以下错误: Executable /home/../foo does not exist. 如果我尝试调试应用程序,弹出 window 错误是:

Starting executable failed: /home/../foo: No such file or directory.

可执行文件已生成,但名称实际上是 food 而不是 foo。所以,很明显为什么 运行 和调试找不到可执行文件。我是 Qt 的新手。我在这里错过了什么?

我找到了两个解决方案:

  1. 在项目->运行 添加新的可执行文件。如果 foo 是第一个,那么为了调试添加一个新的可执行文件,它将被称为 foo2 并且这将指向好的可执行文件 food.

  2. 使用 Qt-creator 4.0.2 安装 Qt5.7 - 开箱即用

我更喜欢第二种。

转到项目->运行 并从 "Run configuration" 按钮组 select "Add" 组合框。然后select"Custom Executable"。

然后浏览 select 可执行文件的路径。

我正在使用 Qt 5.9。