[ ant-contrib-Bugs-2175495 ] ld used even though g++ is specified

"SourceForge.net" <[email protected]> Fri, 17 Apr 2009 06:00:26 +0000
Newsgroups gmane.comp.java.ant-contrib.devel
Message-ID <[email protected]>
Bugs item #2175495, was opened at 2008-10-17 21:19
Message generated for change (Comment added) made by nobody
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=416920&aid=2175495&group_id=36177

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: cpptasks
Group: v1.0 (example)
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Curt Arnold (carnold)
Summary: ld used even though g++ is specified

Initial Comment:
Using the example from the cpptasks website, I am not able to link.  Ant correctly compiles my object, but uses the ld linker instead of g++ causing the build to fail.

I attempted to add a linker tag forcing it to use g++... and that did not work.

Here is some of the error message:
       [cc] obj/main.o(.text+0xa5): In function `main':
       [cc] : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
       [cc] obj/main.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
       [cc] collect2: ld returned 1 exit status

Here is my build.xml:
<project name="MainApp" default="compile">
<taskdef resource="cpptasks.tasks"/>
    <target name="compile">
        <mkdir dir="./obj"/>
        <cc name="g++" outtype="executable" subsystem="console" outfile="./main.exe" objdir="./obj">
           <fileset dir="." includes="*.cpp"/>
           <linker name="g++"/>
        </cc>
    </target>
</project>

I am using cpptasks 1.0 beta 5 with ant 1.7.1 under JDK 6.10.


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2009-04-17 06:00

Message:
Where do you put the <cpptasks:linker> ?
Can you paste the whole xml ?
Thx

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2009-04-07 13:28

Message:
Thanks man for the solution. I was about to go crazy 'cos I couldn't get
even a simple hello world to compile with ant.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2008-10-20 22:37

Message:
I got this working by adding this:
    <cpptasks:linker id="LinuxLinker">
        <libset libs="stdc++"/>
    </cpptasks:linker>

... which I shouldn't have to.
Using g++ to link should pass the required arguments to ld to link a C++
program.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=416920&aid=2175495&group_id=36177

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com