delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/10/31/04:02:35

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 31 Oct 2003 10:08:48 +0100
From: "Gerrit P. Haase" <gp AT familiehaase DOT de>
Reply-To: "Gerrit @ cygwin" <cygwin AT cygwin DOT com>
Organization: Esse keine toten Tiere
X-Priority: 3 (Normal)
Message-ID: <133687559107.20031031100848@familiehaase.de>
To: y2bismil AT engmail DOT uwaterloo DOT ca
CC: cygwin AT cygwin DOT com
Subject: Re: gcc and iostream
In-Reply-To: <1067549281.3fa18261b9137@www.nexusmail.uwaterloo.ca>
References: <1067549281 DOT 3fa18261b9137 AT www DOT nexusmail DOT uwaterloo DOT ca>
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019