48

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?

László Papp
  • 51,870
  • 39
  • 111
  • 135
roosevelt
  • 1,874
  • 4
  • 20
  • 27

4 Answers4

51

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.

roosevelt
  • 1,874
  • 4
  • 20
  • 27
  • 4
    You should not need to clean the build directory, normally. That's what make is for: to use what's there, rebuild what's stale, and give you what you want. – Kuba hasn't forgotten Monica Oct 06 '13 at 21:12
  • 2
    This steps works. But how I can run generated .exe file without moving to debug folder and 'start myexe'? I saw some places saying to run './myproject' but it not work on windows. – Hareen Laks Feb 21 '17 at 06:46
  • What is make.exe and where can I find it? I have only mingw32-make.exe under qt5.7.0\tools\mingw530_32\bin\. If I call mingw32-make.exe instead of make.exe everything works. – Ivars Apr 26 '20 at 08:37
21

In terminal window

  • cd ~/your_project_folder/
  • qmake -project
  • qmake
  • make
Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86
  • 1
    If compiling on a non gui system, you'll need to install qt-devel and qt-create first. Also some distros changed `qmake` to `qmake-qt4` – spuder Oct 15 '14 at 00:06
11

If compiling an existing project, qmake -project is actually wrong, see "qmake --help".

qmake -makefile
make

If its a large project, "make -j4" or similar.

kay
  • 198
  • 1
  • 6
0

I use this method :

  1. open terminal in your project folder .
  2. type : qmake -project . , this will create a .pro file with the same name of the folder where you run the command .
  3. if you have some stuffs of gui add those lines :

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

  1. Finally to build your project : type this command

qmake "your project folder or name ".pro ; qmake make

Mhadhbi issam
  • 197
  • 3
  • 6