X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Message-ID: <48FC5562.1DDA1FAE@dessent.net>
Date: Mon, 20 Oct 2008 02:54:42 -0700
From: Brian Dessent <brian@dessent.net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: [perl] Portably linking to libstdc++
References: <586E6C4720134D06B35A67112D3BBBCE@desktop2> <C9004AE9971E4B7ABBC246E73FC599AF@desktop2> <48FB462B.4B75336B@dessent.net> <BA6845624D6F4E01AA4E2CCEC494A9E5@desktop2>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes
Reply-To: cygwin@cygwin.com
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.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

Sisyphus wrote:

> 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':
> 
> /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 ?

The error means you tried to link an executable that didn't contain a
main() function.  The fact that it refers to a missing WinMain() is
incidental, a byproduct of some compatibility code in Cygwin that
provides a backup main() which calls WinMain(), allowing the
Windows-style tradition where the user provides a WinMain() instead of
main().  Regardless of how it's spelled, you can't link an executable
without a proper entrypoint which is all the error means.

Please post the entire link command and not just the error.  It's
impossible to say what the true nature of the problem is otherwise.  For
example, if you're trying to link a library and not an executable then
the above error would be due to missing the "-shared" flag.

Brian

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

