使用cpptasks使用ant-contrib编译C程序

时间:2011-04-12 15:55:39

标签: ant ant-contrib

这就是我的build.xml文件:

<project name="test" xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks">
    <target name="build-native">
        <mkdir dir="/home/varun/Desktop/lucene/3018-test/check"/>
        <cpptasks:cc outtype="executable" subsystem="console" outfile="BuildNativeDir" objdir="/home/varun/Desktop/lucene/3018-test">
           <fileset file="/home/varun/Desktop/lucene/3018-test/hello.c" />
        </cpptasks:cc>
    </target>
</project>

当我运行命令ant build-native时,我收到错误:

BUILD FAILED
/home/varun/Desktop/lucene/3018-test/build.xml:4: Problem: failed to create task or type antlib:net.sf.antcontrib.cpptasks:cc
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -/usr/share/ant/lib
        -/home/varun/.ant/lib
        -a directory added on the command line with the -lib argument


Total time: 0 seconds

但我的CLASSPATH设置为/usr/share/ant/lib,我已将ant-contrib-1.0b3.jar放入/usr/share/ant/lib/ant-contrib-1.0b3.jar

我做错了什么?

1 个答案:

答案 0 :(得分:4)

{p> cpptask未包含在ant-contrib-*.jar中。你必须单独download

我刚试过cpptasks-1.0-beta5但它没有编译。 cpptasks-1.0-beta4在存档中有一个预编译的jar,运行正常。