X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Message-ID: <6910a60810200030q562bd1b8q9064178bc13cd0e6@mail.gmail.com>
Date: Mon, 20 Oct 2008 09:30:43 +0200
From: "Reini Urban" <rurban@x-ray.at>
To: cygwin@cygwin.com
Subject: Re: [perl] Portably linking to libstdc++
In-Reply-To: <BA6845624D6F4E01AA4E2CCEC494A9E5@desktop2>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <586E6C4720134D06B35A67112D3BBBCE@desktop2> 	 <C9004AE9971E4B7ABBC246E73FC599AF@desktop2> 	 <48FB462B.4B75336B@dessent.net> 	 <BA6845624D6F4E01AA4E2CCEC494A9E5@desktop2>
X-Google-Sender-Auth: b70ab8f74a82ee1d
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

2008/10/20 Sisyphus:
>> Really the correct way to link C++ code is by using g++ which doesn't
>> require this manual -lstdc++ nonsense.  Can't you just do that, by
>> either fixing the makefile to link with $(CXX) or overriding the
>> appropriate variable?

> Aaah ... good point. I had missed something.
>
> I had changed $Config{cc} from 'gcc' to 'g++' thinking that should do the
> trick. And it works fine for MinGW-built perls .... but (as it turns out)
> only because $Config{ld} is already set to 'g++'.

LD is already g++. And if you need to compile C++ you have to use g++
anyway as CC.
No need to change anything in current cygwin perl IMO.

> On both linux and cygwin, I've just realised that $Config{ld} is still set
> to 'gcc' - which is what necessitates linking explicitly to libstdc++.
> Of course, the other option on both linux and cygwin is to set *both*
> $Config{cc} and $Config{ld} to 'g++', and that works fine on linux, but
> doesn't quite work on cygwin where I still get an undefined reference to
> `_WinMain@16':

Current cygwin perl already has g++ as LD for some releases.

> /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab):
> undefined reference to `_WinMain@16'
> collect2: ld returned 1 exit status
>
> Why does that happen ?

Maybe because the linker believes you have a -mwindows GUI app?
Which distro are you talking about?
InlineX::CPP2XS I assume.

> Btw, overriding $Config{cc} and $Config{ld} is trivial. In the Makefile.PL's
> %WriteMakefile() it's just a matter of:
>
>  CC => 'g++',
>  LD => 'g++',
>
> Or they can be overridden from the command line when the Makefile.PL is run:
>
>  perl Makefile.PL CC="g++" LD="g++"

  perl Makefile.PL CC="g++"
should be enough.

> And I think that's all I need do on any perl build where g++ is the name of
> the c++ compiler .... except for Cygwin (where it doesn't work because of
> that undefined reference to `_WinMain@16').
-- 
Reini Urban
http://phpwiki.org/              http://murbreak.at/

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

