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: mingw-targeted cross-compiler question


On Wed, 22 Dec 2010 15:36:01 +0100, Kai Tietz <ktietz70@googlemail.com> wrote:

2010/12/22 <lemkemch@t-online.de>:
On Wed, 22 Dec 2010 15:11:18 +0100, Kai Tietz <ktietz70@googlemail.com>
wrote:

2010/12/22 <lemkemch@t-online.de>:

On Wed, 22 Dec 2010 14:13:15 +0100, Frédéric Bron <frederic.bron@m4x.org>
wrote:


I checked the Make file, it used this flag:
gcc -mno-cygwin -g -Wl,--add-stdcall-alias -Wl,--export-all-symbols
...

replace gcc by gcc-3 gcc 4 is now the default on cygwin but the cross compiler is not supported for that version. Frédéric


Well, I don't know but I'd really like to know what is the replacement these days for

gcc -mno-cygwin -mwindows x.c

I tried

i686-w64-mingw32-gcc -mwindows -m32 x.c

but get

x.c:35:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'WinMain'


and that also for all other option combinations that made sense to me.

Thanks,
Michael

Btw the -m32 is superflous for the i686-w64-mingw32 cross-compiler, as it just produces 32-bit and has no 64-bit capabilities builtin. Could you show please your x.c file, as the message you get is a compiler error already. I would assume that you missed to include some header, or you were defining something which cause here the harm.

Well, the program compiles just fine with the old gcc-3 -mno-cygwin but anyway, here's a stripped down version:


#define WINVER 0x0500 #include <windows.h>

int STDCALL WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int
nShow) {
  return 0;
}


orion> i686-w64-mingw32-gcc -mwindows -m32 xx.c
xx.c:4:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'WinMain'
orion> gcc-3 -mno-cygwin -mwindows -m32 xx.c
orion>




Well, the issue is STDCALL. We don't define this macro. Sorry, can find a single hint on that in msdn. Use here instead the standard WINAPI and it builds on all compilers you are using.

Thanks, that fixed it. Don't know where I got that STDCALL from, it certainly wasn't my invention. However, the size of the executable for that noop program went up from about 21kb to about 100kb. cygcheck lists the same dlls:

 orion> gcc-3 -mno-cygwin -mwindows -m32 xx.c
 orion> ls -ls a.exe
24 -rwxr-x--- 1 michael None 21347 Dec 22 17:18 a.exe
 orion> cygcheck ./a.exe
d:\cygwin\home\michael\a.exe
  C:\WINDOWS\system32\msvcrt.dll
    C:\WINDOWS\system32\KERNEL32.dll
      C:\WINDOWS\system32\ntdll.dll
 orion> i686-w64-mingw32-gcc -mwindows -m32 xx.c
 orion> ls -ls a.exe
100 -rwxr-x--- 1 michael None 100582 Dec 22 17:21 a.exe
 orion> cygcheck ./a.exe
d:\cygwin\home\michael\a.exe
  C:\WINDOWS\system32\KERNEL32.dll
    C:\WINDOWS\system32\ntdll.dll
  C:\WINDOWS\system32\msvcrt.dll

Why would that be?

Michael


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