Can not compile, can not fix - help me...

  • Glass Knife
    Glass Knife

    This is my first try using the cc ant task.  I am running fedora core 8, g++ 4.1.2, and ant 1.7.0.

    Here is the *.cpp file...

    #include <iostream>
    using namespace std;

    int main(int argc, char **argv) {
        cout << "CppTest001 - Hello World!" << endl;
        return 0;

    Here is the build script...

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="CppTest001" default="default" xmlns:cpptasks="antlib:net.sf.antcontrib.cpptasks">
        <target name="default" description="Testing the C++ stuff">
            <mkdir dir="target/main/obj"/>
            <cpptasks:cc outtype="executable" subsystem="console" outfile="target/hello" objdir="target/main/obj">
                <compiler name="g++"/>
                <linker name="g++"/>
                   <fileset dir="src" includes="*.cpp"/>

    Here is the output...

    [cpptasks:cc] Starting dependency analysis for 1 files.
    [cpptasks:cc] 1 files are up to date.
    [cpptasks:cc] 0 files to be recompiled from dependency analysis.
    [cpptasks:cc] 0 total files to be compiled.
    [cpptasks:cc] Starting link
    [cpptasks:cc] main/obj/main.o: In function `__static_initialization_and_destruction_0(int, int)':
    [cpptasks:cc] main.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
    [cpptasks:cc] main/obj/main.o: In function `__tcf_0':
    [cpptasks:cc] main.cpp:(.text+0x6c): undefined reference to `std::ios_base::Init::~Init()'
    [cpptasks:cc] main/obj/main.o: In function `main':
    [cpptasks:cc] main.cpp:(.text+0x8e): undefined reference to `std::cout'
    [cpptasks:cc] main.cpp:(.text+0x93): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
    [cpptasks:cc] main.cpp:(.text+0x9b): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
    [cpptasks:cc] main.cpp:(.text+0xa3): 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> >&))'
    [cpptasks:cc] main/obj/main.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
    [cpptasks:cc] collect2: ld returned 1 exit status

    /CppTest001/build.xml:5: gcc failed with return code 1

    Total time: 0 seconds

    I am sure I am doing something wrong, but I have no idea what to do.  I have tried compiling everything from the command line, and it works fine.

    Any help here would be great.  I love using ANT, and since I do not know a lot about make files, I would really like to get this working.