This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++ linker problem with libcygwin.a


On 10/22/2011 2:18 PM, Philipp Kraus wrote:

> I use Cygwin with g++ for compiling my source codes and on some codes I
> get the error:
> 
> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9):
> undefined reference to `_WinMain@16'
[snip]

That means the linking is being done for a GUI application.  I guess you
wanted to build a console application, so you should learn what these
options for the linker mean:

-Wl,-subsystem,console
-Wl,-subsystem,windows

There are equivalent options used with the compiler g++, I think they are:

-mconsole
-mwindows

In general there are many options that apply only to Windows builds, for
instance building Qt GUI applications I use these for the linker:

-Wl,-enable-stdcall-fixup -Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc -Wl,-as-needed

but they are not for solving linking errors, just to quiet the warnings,
and try to optimize the result.
-- 
René Berber



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]