Trouble compiling a C++ Program

Gareth Pearce tilps@hotmail.com
Wed Nov 28 00:47:00 GMT 2001


> Hallo Craig,
>
> Am 2001-11-28 um 07:24 schriebst du:
>
> > I have downloaded the latest version of CygWin. When I
> > compile the following C++ program:
>
> > // Filename: Welcome.cpp
> > // A first program in C++
> > #include <iostream.h>
>
> > int main()
> > {
> > cout << "Welcome to C++!\n";
>
> > return 0;
> > }
>
> > gcc pops out the following error:
>
> > welcome.cpp: undefined reference to `cout'
>
> > So my question is, how do I get Cygwin to compile this
> > program?
>
> $ g++ -o hello2 hello2.cc
>
> $ hello2
> Welcome to C++!
>
> I remember that if you use the extension .cc, gcc calls g++
> automagically, but it doesn't work.

which is i believe because g++ invoked directly has an implied -lstdc++
if you do gcc -lstdc++ it will also compile just fine.  Ofcourse g++ is
probably a better move for some reason... (other then reduced typing)
>
> Ciao,
>
> Gerrit P. Haase                            mailto:gp@familiehaase.de
> --
> =^..^=
>
>
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
>
>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list