Well I'm glad to hear you were searching the internet for solutions 
to your problems.  I hope you started at http://gcc.gnu.org/.  

Turns out, this isn't a tool problem at all (I know, you didn't imply 
that it was).  It's a usage problem.  And actually, the Cygwin email 
archives is full of inquiries and responses with just this kind of 
problem, even though the issue is not Cygwin-specific.  Your problem is 
that you compiled with the C++ front-end (g++) but then linked with the 
C library (-lc) instead of the C++ library.  But that's just the tip of 
the iceberg in this case.  If you really just want to create an executable,
just use 'g++ -o test test.cpp'.  This will work for you.  By the way,
'test'
is a really bad name for an executable.  It hides the name of the shell 
script built-in.

Larry


Original Message:
-----------------
From: Trimurthi, Swamy(IE10) [EMAIL PROTECTED]
Date: Mon, 23 Dec 2002 07:17:48 -0700
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: RE: linking problem, please help


Hi Igor,
        Thanks for the information and guidance. I will avoid sending
personal mails hereafter.
regards,
Trimurthi 

> -----Original Message-----
> From: Igor Pechtchanski [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, December 23, 2002 7:55 PM
> To:   Trimurthi, Swamy(IE10)
> Cc:   [EMAIL PROTECTED]
> Subject:      Re: linking problem, please help
> 
> Trimurthi,
> 
> The cygwin mailing list is the proper place for such inquiries.  It is
> strongly discouraged to send personal mail with such requests, and they
> will, in general, be ignored.  I've forwarded this request to the proper
> mailing list, and reset the Reply-to: field accordingly for your
> convenience.
>       Igor
> 
> On Mon, 23 Dec 2002, Trimurthi, Swamy(IE10) wrote:
> 
> > Hi Pechta,
> >      I found your mail id while searchig for some solution on the
> internet
> > regarding a linking problem I am facing. It would be of great help to me
> if
> > I can get some guidance from you.  I am using cygwin version [ GNU bash,
> > version 2.05.0(8)-release (i686-pc-cygwin) ] on a WinNT machine, x86
> > processor. I was trying to link the following sample code
> >
> > *************************************
> >
> > #include<iostream>
> >
> > int main()
> > {
> >     cout<<"\n hello world";
> >     return 0;
> > }
> >
> > **************************************
> > I was able to compile the code using the following command
> > g++ -c test.cpp
> > and generated the object code test.o, but I was not able to link it
> using ld
> > and hence unable to generate the exe
> > I gave the ld command and following was the output
> > *************************************************
> > $ ld -o test C:/cygwin/lib/crt0.o test.o -lc
> > test.o(.text+0x24):test.cpp: undefined reference to `cout'
> > test.o(.text+0x29):test.cpp: undefined reference to
> > `ostream::operator<<(char const *)'
> > test.o(.text$__tf3ios+0x29):test.cpp: undefined reference to `__rtti_si'
> > test.o(.text$__tf9streambuf+0x29):test.cpp: undefined reference to
> > `__rtti_si'
> > test.o(.text$__tf7filebuf+0x29):test.cpp: undefined reference to
> `__rtti_si'
> > test.o(.text$__tf7ostream+0x28):test.cpp: undefined reference to
> > `__rtti_class'
> > test.o(.text$__tf7istream+0x28):test.cpp: undefined reference to
> > `__rtti_class'
> > test.o(.text$__tf8iostream+0x30):test.cpp: undefined reference to
> > `__rtti_class'
> > test.o(.text$__tf22_IO_istream_withassign+0x28):test.cpp: undefined
> > reference to `__rtti_class'
> > test.o(.text$__tf22_IO_ostream_withassign+0x28):test.cpp: undefined
> > reference to `__rtti_class'
> > test.o(.text$__tf11_ios_fields+0x1d):test.cpp: undefined reference to
> > `__rtti_user'
> > test.o(.text$__tf8_IO_FILE+0x1d):test.cpp: undefined reference to
> > `__rtti_user'
> > /usr/lib/libc.a(_cygwin_crt0_common.o): In function
> `cygwin_crt0_common':
> >
> /cygnus/netrel/src/cygwin-1.3.3-2/winsup/cygwin/lib/_cygwin_crt0_common.cc
> :9
> > 0: undefined reference t
> > o `GetModuleHandleA@4'
> > **************************************************
> > Could you guide me like where the problem is and whether do I need to
> > include crtbegin and crtend files. When these files are generally
> required.
> > I am eager to hear from you
> >
> > thanks in advance,
> > regards,
> > Trimurthi
> 
> -- 
>                               http://cs.nyu.edu/~pechtcha/
>       |\      _,,,---,,_              [EMAIL PROTECTED]
> ZZZzz /,`.-'`'    -.  ;-;;,_          [EMAIL PROTECTED]
>      |,4-  ) )-,_. ,\ (  `'-'         Igor Pechtchanski
>     '---''(_/--'  `-'\_) fL   a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!
> 
> Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
>   -- /usr/games/fortune

--
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/


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .



--
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/

Reply via email to