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.
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.
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.
Where do you put the <cpptasks:linker> ?
Can you paste the whole xml ?
Thx