X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: From: "Sisyphus" To: References: <586E6C4720134D06B35A67112D3BBBCE AT desktop2> <48FB462B DOT 4B75336B AT dessent DOT net> In-Reply-To: <48FB462B.4B75336B@dessent.net> Subject: Re: [perl] Portably linking to libstdc++ Date: Mon, 20 Oct 2008 17:53:30 +1100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Windows Mail 6.0.6001.18000 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com ----- Original Message ----- From: "Brian Dessent" >> But on cygwin, there is no '-lstdc++' to be found in $Config{libpth}, so >> MakeMaker decides to not pass the switch on (which has always been >> MakeMaker's policy in such cases, afaik). This is a pity - there would be >> no >> problem if it *did* the pass switch on, as both gcc and g++ on cygwin >> will >> resolve that link. > > MakeMaker should be fixed to allow the switch through. > This has been a long standing feature of MakeMaker, and I expect that a significant number of modules would be broken if that behaviour was changed. It allows module authors the convenience of being able to specify all libs that might be needed, without having to worry about the fact that some of those libs will be both unneeded and absent on some systems. At least, I *guess* that's the idea behind it. It would be better, however, if there was some way to override that behaviour and force MakeMaker to pass the switch on. (I don't think such a facility exists ... but I couldn't say for sure ...) > > 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++'. 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 AT 16': /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab): undefined reference to `_WinMain AT 16' collect2: ld returned 1 exit status Why does that happen ? 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++" 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 AT 16'). Thanks for the reply, Brian. Cheers, Rob -- 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/