40

I am developing a application using Qt, the C++ library/framework. Using the QT-Creator I can compile my project just fine and the build directory generates the desired executable files just fine. However, I am trying to automate my asks and using Apache ANT. But I am running into the following issues.

Here is the output from the command line:

build.mac.64:
     [echo] Building for Mac
     [echo] Updating destination path
     [exec] Project WARNING: No .qmake.cache is present. This significantly slows down qmake with this makespec.
     [exec] Project WARNING: Call 'cache()' in the top-level project file to rectify this problem.
     [exec] make: Nothing to be done for `first'.
     [exec] cp: ./build/mac.64/settings.ini: No such file or directory
     [exec] Result: 1
     [echo] Reverting destination path

I am not sure why it is not compiling the executable file.

Here is how my target looks like:

<target name="build.mac.64">
    <echo>Building for Mac</echo>
    <exec executable="qmake">
        <arg value="myproject.pro"/>
        <arg
        value="-r"/>
        <arg value="-spec"/>
        <arg value="macx-clang"/>
        <arg value="CONFIG+=x86_64"/>
    </exec>

    <exec executable="make" />

    <exec executable="cp">
        <arg value="./settings.ini"/>
        <arg value="${default.build.dir.mac.64}/settings.ini"/>
    </exec>

</target>

Any idea where I am going wrong?

4

4 回答 4

45

谢谢提醒伙计。我意识到我做错了什么。QT-Creator 实际上默默地采取了前两个步骤。

  1. 创建构建输出目录
  2. CD 到构建输出目录(关键步骤)
  3. 调用 qmake 引用 .pro 文件
  4. 拨打电话

所以,我忽略的关键是你必须首先在构建目录中,然后调用 qmake、make 等......而且如果构建已经编译了文件,它会抛出该错误。我只需要确保清理构建目录以重新编译所有内容。

于 2013-10-06T16:56:49.070 回答
19

在终端窗口中

  • cd ~/your_project_folder/
  • qmake-项目
  • qmake
  • 制作
于 2013-10-06T21:29:30.457 回答
10

如果编译现有项目,qmake -project 实际上是错误的,请参阅“qmake --help”。

qmake -makefile
make

如果它是一个大项目,“make -j4”或类似的。

于 2017-02-12T15:48:12.070 回答
0

我使用这种方法:

  1. 在您的项目文件夹中打开终端。
  2. 键入:qmake -project .,这将创建一个与您运行该命令的文件夹同名的 .pro 文件。
  3. 如果你有一些 gui 的东西,请添加这些行:

QT += 核心 gui

大于(QT_MAJOR_VERSION,4):QT += 小部件

  1. 最后构建你的项目:输入这个命令

qmake "你的项目文件夹或名称 ".pro ; qmake 制作

于 2021-12-07T13:08:48.757 回答