You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by fabien_pichard <fa...@hotmail.com> on 2007/11/27 01:30:46 UTC

linking with CC task

Hello,
I went to http://ant-contrib.sourceforge.net/cc.html to try to understand
how linking worked but I still cannot make it work at all...
Anyways,
here is my code

<project name="C build" basedir="."
xmlns:cpptasks="antlib:org.sf.net.antcontrib.cpptasks" 
xmlns:antcontrib="antlib:net.sf.antcontrib">

  <taskdef uri="antlib:net.sf.antcontrib"
          resource="net/sf/antcontrib/antcontrib.properties"
          classpath="${ant.home}/lib/ant-contrib-1.0b3.jar"/>
	<taskdef resource="cpptasks.tasks"
					 classpath="${ant.home}/lib/cpptasks.jar"/> 
 <typedef resource="cpptasks.types"/> 
 <path id="cc.classpath"> 
    <pathelement location="lib/cpptasks.jar"/> 
  </path> 

  <target name="cmpdebug" depends="init" description="Compile the source " >
    <cc name="msvc" 
	objdir="${debug.dir}" 
	debug="1"   
	rebuild="1"
	warnings="severe" 
	optimize="none" 
	exceptions="true"> 
	<fileset dir="${src}" includes="*.c"/> 

	<compiler name="msrc"
		debug="1"
		rebuild="1"
		warnings="severe">
		<fileset dir="${debug.dir}" includes="*.rc"/>
	</compiler>

	<linker name="msvc"
		debug="1"
		rebuild="1">
		<fileset dir="${debug.dir}" includes="*.obj"/>
	</linker>

 </target>

It will compile and I will have an OBJ, but it won't link... and ANT does
not fail anywhere...
What am I doing wrong?

Thanks -- fabien
-- 
View this message in context: http://www.nabble.com/linking-with-CC-task-tf4878970.html#a13962292
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: linking with CC task

Posted by fabien_pichard <fa...@hotmail.com>.
Hello Dominique,
Thank you for your answer.

Actually I found out why my stuff was not working... I guess working long
hours on the same thing gets me  blind and I did not see a simple thing:
I did not have the outtype=${debug.dir}\${exename} in the CC command.
So it never launched the linker... 

I have been using ant -verbose or -debug all the time... 
Anyways...
Here is the final ant task if anyone needs help on CC tasks compiler,
resource compiler and linker from microsoft.
     
- <cc name="msvc" 
                  objdir="${release.dir}" 
                  debug="0" 
                  rebuild="1" 
                  incremental="0" 
                  warnings="severe" 
                  failonerror="1" 
                  optimize="speed" 
                  exceptions="true" 
                  outfile="${release.dir}/${exename}" 
                  link="executable" 
                  outtype="executable" 
                  subsystem="console">
                    <fileset dir="${src}" includes="*.c" /> 
                  <compiler name="msrc" debug="0" rebuild="1"
warnings="severe">
                    <fileset dir="${release.dir}" includes="*.rc" /> 
                  </compiler>
                  <linker name="msvc" debug="0" incremental="0" rebuild="1">
                    <fileset dir="${release.dir}" includes="*.obj" /> 
                    </linker>
  </cc>

-- fabien
-- 
View this message in context: http://www.nabble.com/linking-with-CC-task-tf4878970.html#a14033245
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: linking with CC task

Posted by Dominique Devienne <dd...@gmail.com>.
On Nov 26, 2007 6:30 PM, fabien_pichard <fa...@hotmail.com> wrote:
> I went to http://ant-contrib.sourceforge.net/cc.html to try to understand
> how linking worked but I still cannot make it work at all...
>
> <project name="C build" basedir="."
> xmlns:cpptasks="antlib:org.sf.net.antcontrib.cpptasks"
> xmlns:antcontrib="antlib:net.sf.antcontrib">

Since you've put cpptasks.jar in ${ant.home}/lib, and you use
xmlns:cpptasks, you don't need to <taskdef> and <typedef> it. Simply
use <cpptasks:cc> instead.

And if cpptasks.jar wasn't in ${ant.home}/lib, you'd have to have used
a loaderref so the <taskdef> and <typedef> used the same class loader.
Just in FYI.

Same applies to Ant-Contrib. So use xmlns or task/typedef, but not both.

>   <target name="cmpdebug" depends="init" description="Compile the source " >
>     <cc name="msvc"
>         objdir="${debug.dir}"
>         debug="1"
>         rebuild="1"
>         warnings="severe"
>         optimize="none"
>         exceptions="true">

Don't you need to specify whether it's a .exe or .dll? It's been a while...

>         <linker name="msvc"
>                 debug="1"
>                 rebuild="1">
>                 <fileset dir="${debug.dir}" includes="*.obj"/>
>         </linker>

I don't think you need an explicit linker, since you used <cc
name="msvc">, and you also don't need to use a fileset for obj, as
<cc> knows about them as products of the compilation of the C sources.

I don't have my CppTasks builds with me anymore, and it's been a
couple years, so it's becoming fuzzy...

> It will compile and I will have an OBJ, but it won't link... and ANT does
> not fail anywhere...
> What am I doing wrong?

Try running with -verbose, and study the output. Might provide some
insight. --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org