On Thu, 12 Sep 2002, Binand Raj S. wrote:

> ie, please demonstrate how you'd compile a C++ program with a purely
> C compiler.

;) i was pretty sure Binand would. I didnt say a _purely_ C compiler, i was
speaking in terms of gcc. So here goes

<script file >
Script started on Thu Sep 12 20:02:37 2002
[srean@srean]$.cat - >a.cxx
#include <iostream>

int main (void) {
            cout << "Hello World" << endl;
                return 0;
}

[srean@gatesssrean]$ gcc a.cxx

/home/srean/tmp/ccV2qvgM.o: In function `main':
/home/srean/tmp/ccV2qvgM.o(.text+0xa): undefined reference to `endl(ostream &)'
/home/srean/tmp/ccV2qvgM.o(.text+0x17): undefined reference to `cout'
/home/srean/tmp/ccV2qvgM.o(.text+0x1c): undefined reference to 
`ostream::operator<<(char const *)'
/home/srean/tmp/ccV2qvgM.o(.text+0x27): undefined reference to 
`ostream::operator<<(ostream &(*)(ostream &))'
collect2: ld returned 1 exit status


[srean@srean]$egcc.a.cxx -lstdc++
[srean@srean]$ea.out
Hello World
Script done on Thu Sep 12 20:03:37 2002
</end script file>


note that even in the 1st invocation of gcc the compiles but doesnt link,
which you can fix by linking explicitly to the c++ libraries. In the
earlier versions g++ was just a as cript calling gcc and doing this. Now
it comes up as a binary but i guess the modus operandi is the same



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to