delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/05/14:20:28

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
Reply-To: Cygwin List <cygwin AT cygwin DOT com>
Message-Id: <6.0.1.1.0.20040305141623.03d2af70@127.0.0.1>
X-Sender:
Date: Fri, 05 Mar 2004 14:18:05 -0500
To: Xavier Dufresne <xdufresne AT gmx DOT fr>, cygwin AT cygwin DOT com
From: Larry Hall <cygwin-lh AT cygwin DOT com>
Subject: Re: Undefined references when compiling C++ program
In-Reply-To: <4048CE1D.30000@gmx.fr>
References: <4048CE1D DOT 30000 AT gmx DOT fr>
Mime-Version: 1.0

At 01:59 PM 3/5/2004, you wrote:
>Hello,
>
>when I try to compile this...
>
>//zozo.cc
>#include <iostream>
>int main()
>{
> std::cout << "Salut" << std::endl;
> return 0;
>}
>
>...with...
>gcc zozo.cc
>
>...gcc give me...
>/cygdrive/c/DOCUME~1/travonz/LOCALS~1/Temp/ccuTTqP6.o(.text+0x2f):zozo.cc: undefined reference to `std::cout'
>/cygdrive/c/DOCUME~1/travonz/LOCALS~1/Temp/ccuTTqP6.o(.text+0x34):zozo.cc: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
>/cygdrive/c/DOCUME~1/travonz/LOCALS~1/Temp/ccuTTqP6.o(.text+0x3c):zozo.cc: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
>/cygdrive/c/DOCUME~1/travonz/LOCALS~1/Temp/ccuTTqP6.o(.text+0x44):zozo.cc: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
>/cygdrive/c/DOCUME~1/travonz/LOCALS~1/Temp/ccuTTqP6.o(.text+0x6d):zozo.cc: undefined reference to `std::ios_base::Init::Init[in-charge]()'
>/cygdrive/c/DOCUME~1/travonz/LOCALS~1/Temp/ccuTTqP6.o(.text+0x88):zozo.cc: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
>collect2: ld returned 1 exit status
>
>if I compile: int main(){return 0;} it's ok !
>
>Do I have to specifie linking libraries with the -l option ?


Ugh!

Did you think of checking the email archives?  Do you realize this question
is really not Cygwin-specific so it's off-topic?  Anyway, use 'g++' to 
compile C++ source.



--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


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