ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <>
Subject Re: Ant novice and cpptasks
Date Fri, 17 Oct 2003 02:00:11 GMT
Deidre McClain wrote:

>I've just begun to use Ant and my project is to execute a build in Ant of
>c++ source code.  I've installed the cpptasks and have the following in my
>build file:
><taskdef resource="cpptasks.tasks"/>
><typedef resource="cpptasks.types"/>
><taskdef name="cc" classname="net.sf.antcontrib.cpptasks.CCTask"/>
><typedef name="linker" classname="net.sf.antcontrib.cpptasks.LinkerDef"/>
><typedef name="compiler"
><cc name="gcc" debug="true" exceptions="true" incremental="true"
>link="static" objdir="${basedir.bld.database.dir}" outfile="fcmsgs.o">
>	<compiler name="gcc">
>		<fileset dir="${basedir.bld.database.dir}">
>			<include name="fcmsgs.c"/>
>			<include name="fcmsgs.h"/>
>		</fileset>
>	</compiler>
>	<linker name="gcc"></linker>
First, please use the 
mailing list for questions about cpptasks and for follow ups to this 

The CreateProcess exception is most likely due to gcc not being on the 
path.  Can you run gcc from the command  prompt that you used to run 
ant?  Can you use the <exec> task to run gcc?

Now for the picky parts. 

<taskdef resource=".."/> or <taskdef name=".." classname=".."/>  are two 
different ways of doing the same thing.  You only need one of them (same 
goes for typedef)

You do not need to include header files in the fileset. 

By specifying outfile="fcmsgs.o", you are requesting the linker to call 
the resulting library "libfcmsgs.a".  Actually, that might be a bug and 
the file should be named libfcmsgs.o.a, I'll have to check.  A platform 
appropriate prefix and/or extension is added, the same outfile would 
produce fcmsgs.dll on Windows.  If you just wanted to compile only, omit 
the outfile attribute.

Nested compiler and linker elements allow you to mix and match tools and 
settings.  If you are only using gcc to compile everything, you can just 
put the <fileset> as a child of <cc>

Generally, you would not want to the directory where object (.o) files 
are generated (objdir) to be the same as the source directory.  You 
would typically want to delete all the generated .o files during a clean 
target and it makes it a whole lot easier, if they aren't mixed up with 
your source files.

Here my take on your project:

<project default="compile-fcmsgs">
<taskdef resource="cpptasks.tasks"/>
<typedef resource="cpptasks.types"/>

<property name="basedir.bld.database.dir" location="."/>
<property name="obj.dir" location="./obj/debug"/>

<target name="compile-fcmsgs">
<mkdir dir="${obj.dir}"/>
<cc name="gcc" debug="true" exceptions="true"
link="static" objdir="${obj.dir}" outfile="fcmsgs">
        <fileset dir="${basedir.bld.database.dir}" includes="fcmsgs.c"/>

"Java Development With Ant" by Erik Hatcher and Steve Loughran contains 
a chapter on using cpptasks and would be a useful companion to any Ant 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message