views:

147

answers:

1

Hi all,

I'm using NetBeans C++ to build a simple Qt application. Here is what I did:

  1. From 'File' I chose 'New project'
  2. In the 'New project' window I selected C/C++ category and C/C++ Qt application
  3. Then I clicked Next and on the second frame I renamed my project to 'Test'
  4. Clicked 'Finish' and the sample project was created successfully (is is also the only project open so it is treated as the main project).
  5. From 'Run' I chose 'Build Main Project' - the action was successful
  6. Then I created an Ant script to build the same project from the console:

    Linux projects build

    <target name="My.Test">
        <echo>Building my Test Linux project.</echo>
    <exec executable="make" failonerror="true" dir="Test">
            <arg value="-f"/>
            <arg value="Makefile"/>
            <arg value="clobber"/>
        </exec>    
    </target>        
    

    When I run this script I get a peculiar error:

Test.linux: [echo] Building my Test Linux project.

My.Test:
     [echo] Building my Test Linux project.
     [exec] for CONF in Debug Release ; \
     [exec]     do \
     [exec]         "make" -f nbproject/Makefile-${CONF}.mk QMAKE= SUBPROJECTS= .clean-conf; \
     [exec]     done
     [exec] make[1]: Entering directory `/home/myusr/Development/Projects/Test'
     [exec] VPATH=. -o qttmp-Debug.mk nbproject/qt-Debug.pro
     [exec] /bin/sh: -o: not found

The build fails. After looking at the make files I found the following lines in Makefile-Debug.mk:

# Link Libraries and Options
LDLIBSOPTIONS=

nbproject/qt-${CND_CONF}.mk: nbproject/qt-${CND_CONF}.pro FORCE
    ${QMAKE} VPATH=. -o qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.pro
    mv -f qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.mk

I don't understand why '${QMAKE} VPATH=. -o qttmp-${CND_CONF}.mk nbproject/qt-${CND_CONF}.pro' is unacceptable and what is actually wrong.

After some pondering I noticed that NetBeans sets the value of ${QMAKE} to /usr/bin/qmake, but when I call the ant script it stays an empty string. So my question is rather how NetBeans knows where to find the qmake - is there a project setting or is it a setting of the IDE itself. Should I rely on the fact that the qmake path is always this '/usr/bin/qmake' and set ${QMAKE} variable in the ant script manually or is there another way to solve this?

10x in advance

A: 

Qt itself uses QTDIR to check which installation to use in case if you have several versions installed. Some linux distributions doesn't set this environment variable since in most cases it's not needed.

Good way to find out which Qt version to use is:

1) Check if ${QTDIR} exists. In this case qmake is located under ${QTDIR}/bin directory

2) If ${QTDIR} doesn't exists try to find qmake in the directories specified by ${PATH} env variable. For example using which command.

This method is used by SCons qt4 build tool (unofficial third party module for this build system). I think it should be simple to implement this algorithm with ant.

VestniK
10x, hopefully this might solve my issue.