Menu

help - g++ hangs during build

Help
Tao Yang
2006-06-02
2013-04-24
  • Tao Yang

    Tao Yang - 2006-06-02

    I am newbie to cpptask but familiar with ant; this is my first build.xml with cpptask, however, it mysteriously fails:

    when fire the build with ant, the target contains "cc" task always hangs. I take a look from windows task manager, it seems g++ is hanging; if I end g++ process from the task manager, the build actually proceed and finish successfully - it does build what I intend to build.

    My question is, what have I did wrong to cause this annoying behavior?

    My ant version: 1.6.5
    ant-contrib: 1.0b2
    cpptask: 1.0b4
    I am using mingw 3.9 with msys 1.0.10 on windowsXP with everything up-to-date;

    following is my build.xml:
    <?xml version="1.0"?>

    <project name="test" default="buildAll">

    <property name="base.dir" value="."/>
    <property name="debug" value="true"/>
    <property name="compiler" value="g++"/>
    <property name="src.dir" location="${base.dir}/src"/>
    <property name="test.dir" location="${base.dir}/test"/>
    <property name="build.dir" location="build"/>
    <property name="obj.dir" location="${build.dir}/obj"/>  
    <property name="include.dir" location="${base.dir}/include"/>
    <!-- specify api="unix" or api="win32" override platform default -->
    <property name="api" value="default"/>

    <taskdef resource="cpptasks.tasks"/>
    <typedef resource="cpptasks.types"/>

    <target name="usage">
        <echo message="Builds test"/>
        <echo message="Usage:"/>
        <echo message="ant -Dcompiler=[gcc | msvc ...]"/>
    </target>

    <target name="init">
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${obj.dir}"/>
        <condition property="is-gcc">
            <or>
                <equals arg1="${compiler}" arg2="gcc"/>
                <equals arg1="${compiler}" arg2="g++"/>
            </or>
        </condition>
        <condition property="is-msvc">
            <or>
                <equals arg1="${compiler}" arg2="msvc"/>
            </or>
        </condition>
        <condition property="is-windows">
            <os family="windows"/>
        </condition>
        <condition property="is-win32">
            <or>
                <equals arg1="${api}" arg2="win32"/>
                <and>
                    <equals arg1="${api}" arg2="default"/>
                    <isset property="is-windows"/>
                </and>
            </or>
        </condition>
        <property environment="env"/>
        <!--  in case not set in environment, use an insignificant value -->
        <property name="env.LD_LIBRARY_PATH" value="."/>
        <property name="opencv.dir" value="${env.OPENCV_HOME}"/>
        <property name="opencv.lib.dir" value="${opencv.dir}/lib"/>  
    </target>

    <target name="clean">
        <delete dir="${build.dir}"/>
    </target>

    <target name="buildSegmentor" depends="init">
        <mkdir dir="${obj.dir}"/>
        <cc objdir="${obj.dir}"
            debug="${debug}"
            outtype="executable"
            exceptions="true"
            optimize="speed"
            outfile="${build.dir}/testSeg.exe">
            <includepath path="${opencv.dir}/cv/include"/>
            <includepath path="${opencv.dir}/cvaux/include"/>
            <includepath path="${opencv.dir}/cxcore/include"/>
            <includepath path="${opencv.dir}/otherlibs/highgui"/>
            <includepath path="${opencv.dir}/otherlibs/cvcam/include"/>
            <includepath path="${src.dir}/img"/>
            <compiler id="cp" name="${compiler}"/>     
            <fileset dir="${src.dir}/core" includes="*.cpp"/>
            <fileset dir="${src.dir}/img" includes="*.cpp"/>
            <fileset dir="${src.dir}/video" includes="*.cpp"/>
            <fileset dir="${test.dir}" includes="testSegmentor.cpp"/>
            <linker name="g++" if="is-gcc"/>     
            <libset dir="${opencv.lib.dir}" libs="cv, cvaux, cxcore, highgui"/>
            <defineset define="WIN32" if="is-win32"/>
        </cc>
    </target>
       
    <target name="buildOptiFlow" depends="init">
            <mkdir dir="${obj.dir}"/>
            <cc objdir="${obj.dir}"
                debug="${debug}"
                outtype="executable"
                exceptions="true"
                rtti="true"
                optimize="speed"
                outfile="${build.dir}/testOptiFlow.exe">
                <includepath path="${opencv.dir}/cv/include"/>
                <includepath path="${opencv.dir}/cvaux/include"/>
                <includepath path="${opencv.dir}/cxcore/include"/>
                <includepath path="${opencv.dir}/otherlibs/highgui"/>
                <includepath path="${opencv.dir}/otherlibs/cvcam/include"/>
                <includepath path="${src.dir}/img"/>
                <compiler id="cp" name="${compiler}"/>     
                <fileset dir="${src.dir}/core" includes="*.cpp"/>
                <fileset dir="${src.dir}/img" includes="*.cpp"/>
                <fileset dir="${src.dir}/video" includes="*.cpp"/>
                <fileset dir="${test.dir}" includes="testOpticalFlow.cpp"/>
                <linker name="g++" if="is-gcc"/>     
                <libset dir="${opencv.lib.dir}" libs="cv, cvaux, cxcore, highgui"/>
                <defineset define="WIN32" if="is-win32"/>
            </cc>
        </target>

    <target name="buildAll" depends="buildSegmentor, buildOptiFlow"/>

    </project>

     
    • Nan HUANG

      Nan HUANG - 2007-04-04

      I have the same problem under windows xp using MingW-GCC, my ant version is ant 1.6.5, I tried the svn version, error too.

       
    • Nan HUANG

      Nan HUANG - 2007-04-04

      workaround, instead of using <libset> in the <linker> part, I used <linkerarg> with full command-line options explicitly.

       
      • Dennis Kennedy

        Dennis Kennedy - 2008-06-25

        The workaround didn't work for me, as it put the libraries at the beginning of the command line.

         

Log in to post a comment.