Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <114780-2200212123154339854@M2W034.mail2web.com> X-Priority: 3 Reply-To: lhall AT rfk DOT com X-Originating-IP: 209.113.174.244 From: "lhall AT pop DOT ma DOT ultranet DOT com" To: trimurthi DOT swamy AT honeywell DOT com, cygwin AT cygwin DOT com Subject: RE: linking problem, please help Date: Mon, 23 Dec 2002 10:43:39 -0500 MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 X-OriginalArrivalTime: 23 Dec 2002 15:43:39.0870 (UTC) FILETIME=[108607E0:01C2AA9A] Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id gBNG2m111943 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) Trimurthi DOT Swamy AT honeywell DOT com Date: Mon, 23 Dec 2002 07:17:48 -0700 To: cygwin AT cygwin DOT com, Trimurthi DOT Swamy AT honeywell DOT com 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:pechtcha AT cs DOT nyu DOT edu] > Sent: Monday, December 23, 2002 7:55 PM > To: Trimurthi, Swamy(IE10) > Cc: cygwin AT cygwin DOT com > 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 > > > > 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 AT 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/ > |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu > ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com > |,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/