Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
138 views
in Technique[技术] by (71.8m points)

c++ - Compile a Qt project from command Line

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?

question from:https://stackoverflow.com/questions/19206462/compile-a-qt-project-from-command-line

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Thanks for the tips guys. I realized what I was doing wrong. QT-Creator actually takes the first two steps silently.

  1. Create the build output directory
  2. CD to the build output directory (KEY STEP)
  3. Call qmake referencing the .pro file
  4. Call make

So, the key thing that I overlooked was that you had to be in the build directory first and then call qmake, make etc... And also if the build already has the files compiled it throws that error. I just have to make sure I clean the build directory to compile everything fresh.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...