[perl] Portably linking to libstdc++

Brian Dessent brian@dessent.net
Mon Oct 20 09:55:00 GMT 2008


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/



More information about the Cygwin mailing list