Subject: Re: gcc and iostream
From: "Gerrit P. Haase" <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Fri, 31 Oct 2003 10:08:48 +0100

Hallo y2bismil,

Am Donnerstag, 30. Oktober 2003 um 22:28 schriebst du:

> I'm having a linking problem with GCC and iostream.  I'm not sure if it has
> anything to do with cygwin, so I'll check here.

> I am using 
> #include <iostream>
> using namespace std;

> Its a pretty large project.  First, all the sources and compiled into object
> files using gcc.  Then to link, I've tried both gcc and g++.  Both times using
> -lstdc++ as a paramter.  Yet, I always seem to get iostream errors like:

> : undefined reference to `ostream::operator<<(char const*)
> : undefined reference to `_cin'
> : undefined reference to `_cout'
> :undefined reference to `istream& operator>><int>(istream&, smanip<int> const&)'

[...]

> My compile line is:
> gcc/g++
>    -mno-cygwin  -g -o$(_Target)
>    -LC:\cygwin\lib\mingw
>    -Wl,--start-group
>    -lwsock32
>    -lstdc++   
>    <files needed to be linked>
>    -Wl,--end-group    

Put the libraries to the end of the linkline:
 gcc/g++
    -mno-cygwin  -g -o$(_Target)
    -Wl,--start-group
    <files needed to be linked>
    -LC:\cygwin\lib\mingw
    -lwsock32
    -lstdc++
    -Wl,--end-group

And I'm not sure if this works with Cygwin gcc/ld: -LC:\cygwin\lib\mingw

Gerrit
-- 
=^..^=

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/