2011-04-12 99 views
3

這是我的build.xml文件看起來像螞蟻的contrib一個C程序:編譯使用使用cpptasks擴展

<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

我在做什麼錯?

回答

4

cpptask未包含在ant-contrib-*.jar中。你必須單獨地download

我剛剛試過cpptasks-1.0-beta5但它沒有編譯。 cpptasks-1.0-beta4在存檔中有一個預編譯的jar,並且工作正常。

+0

謝謝。這有幫助。我也成功地構建了'cpptasks-1.0-beta5'。我使用這個命令'ant build-tests'並將jar編譯到'/ target/lib /'目錄中。 – varunthacker 2011-04-20 12:55:41

相關問題