public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Cygwin/GCC can't link my code... either.
@ 2002-07-14 22:28 Motivus
  2002-07-14 22:36 ` Robert Collins
  2002-07-14 23:02 ` Michael Beach
  0 siblings, 2 replies; 5+ messages in thread
From: Motivus @ 2002-07-14 22:28 UTC (permalink / raw)
  To: cygwin

But it's only "Hello World!"...

In my case, I'm running W2k & the latest Cygwin. I've searched the list (where
I expected to find my answer right away), the FAQ, the docs... but turned up
nothing.

The code:

#include <iostream>

int main()
{
  std::cout << "Hello world!\n";
  return 0;
}

The message:

$ gcc hello.cpp
/cygdrive/c/DOCUME~1/MOTIVU~1/LOCALS~1/Temp/ccCvXb2l.o(.text+0x24):hello.cpp:
un
defined reference to `cout'
/cygdrive/c/DOCUME~1/MOTIVU~1/LOCALS~1/Temp/ccCvXb2l.o(.text+0x29):hello.cpp:
un
defined reference to `ostream::operator<<(char const *)'
collect2: ld returned 1 exit status

Please help.

motivus

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cygwin/GCC can't link my code... either.
  2002-07-14 22:28 Cygwin/GCC can't link my code... either Motivus
@ 2002-07-14 22:36 ` Robert Collins
  2002-07-14 23:02 ` Michael Beach
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Collins @ 2002-07-14 22:36 UTC (permalink / raw)
  To: Motivus, cygwin

Use g++, not gcc.
Rob

----- Original Message -----
From: "Motivus" <motivus@yahoo.com>
To: <cygwin@cygwin.com>
Sent: Monday, July 15, 2002 1:05 PM
Subject: Cygwin/GCC can't link my code... either.


> But it's only "Hello World!"...
>
> In my case, I'm running W2k & the latest Cygwin. I've searched the list
(where
> I expected to find my answer right away), the FAQ, the docs... but turned
up
> nothing.
>
> The code:
>
> #include <iostream>
>
> int main()
> {
>   std::cout << "Hello world!\n";
>   return 0;
> }
>
> The message:
>
> $ gcc hello.cpp
>
/cygdrive/c/DOCUME~1/MOTIVU~1/LOCALS~1/Temp/ccCvXb2l.o(.text+0x24):hello.cpp
:
> un
> defined reference to `cout'
>
/cygdrive/c/DOCUME~1/MOTIVU~1/LOCALS~1/Temp/ccCvXb2l.o(.text+0x29):hello.cpp
:
> un
> defined reference to `ostream::operator<<(char const *)'
> collect2: ld returned 1 exit status
>
> Please help.
>
> motivus
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Autos - Get free new car price quotes
> http://autos.yahoo.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/
>
>


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cygwin/GCC can't link my code... either.
  2002-07-14 22:28 Cygwin/GCC can't link my code... either Motivus
  2002-07-14 22:36 ` Robert Collins
@ 2002-07-14 23:02 ` Michael Beach
  2002-07-15  8:54   ` Motivus
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Beach @ 2002-07-14 23:02 UTC (permalink / raw)
  To: Motivus, cygwin

On Monday 15 July 2002 13:05, Motivus wrote:
> But it's only "Hello World!"...
>
> In my case, I'm running W2k & the latest Cygwin. I've searched the list
> (where I expected to find my answer right away), the FAQ, the docs... but
> turned up nothing.
>
> The code:
>
> #include <iostream>
>
> int main()
> {
>   std::cout << "Hello world!\n";
>   return 0;
> }
>
> The message:
>
> $ gcc hello.cpp
> /cygdrive/c/DOCUME~1/MOTIVU~1/LOCALS~1/Temp/ccCvXb2l.o(.text+0x24):hello.cp
>p: un
> defined reference to `cout'
> /cygdrive/c/DOCUME~1/MOTIVU~1/LOCALS~1/Temp/ccCvXb2l.o(.text+0x29):hello.cp
>p: un
> defined reference to `ostream::operator<<(char const *)'
> collect2: ld returned 1 exit status
>
> Please help.

Well, I'm reasonably certain that since you're doing a compile + link with 
"gcc" instead of "g++" you'll only be getting the standard C libraries rather 
than the C++ ones. Try using "g++" rather than "gcc", or else explicitly link 
with the standard C++ library using "-lstdc++".

>
> motivus

Regards
M.Beach

>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Autos - Get free new car price quotes
> http://autos.yahoo.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/

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cygwin/GCC can't link my code... either.
  2002-07-14 23:02 ` Michael Beach
@ 2002-07-15  8:54   ` Motivus
  0 siblings, 0 replies; 5+ messages in thread
From: Motivus @ 2002-07-15  8:54 UTC (permalink / raw)
  To: cygwin

Thanks all. Problem solved.

Mvus

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cygwin/GCC can't link my code... either
@ 2002-07-15  0:02 Dockeen
  0 siblings, 0 replies; 5+ messages in thread
From: Dockeen @ 2002-07-15  0:02 UTC (permalink / raw)
  To: cygwin

Motivus wrote:

"I've searched the list(where I expected to find my answer right away), 
the FAQ, the docs... but turned up nothing."

I've found in cases like this it is more productive to go to Google
first.  If there is a reference (FAQ, Manual), it will find it, and
it performs better for me than the search engine in the archive.  In this
case, I searched on
 
gcc "undefined reference to 'cout'" cygwin

and got a number of very good hits that gave the same correction.  In this 
case, this problem is one I run into a lot cuz I fat finger in gcc
rather than g++.  

Wayne Keen

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-07-15 13:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-14 22:28 Cygwin/GCC can't link my code... either Motivus
2002-07-14 22:36 ` Robert Collins
2002-07-14 23:02 ` Michael Beach
2002-07-15  8:54   ` Motivus
2002-07-15  0:02 Dockeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).