How can I make 64-bit compiles with Cygwin?

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

User avatar
hgm
Posts: 27701
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

How can I make 64-bit compiles with Cygwin?

Post by hgm »

I have a 64-bit computer now, and installed Cygwin on it. When I run GCC (version 3.4.4) on it in the usual way, it produces 32-bit binaries, however. So I tried to compile with the -m64 flag, and it says:

Code: Select all

$ gcc -mno-cygwin -m64 -O2 -s sdk.o mini2.c -o sdk-64.exe
mini2.c:1: sorry, unimplemented: 64-bit mode not compiled in
OK, so I went back to the Cygwin setup, and selected package mingw64-x86_64-gcc-core (and dependencies), which sounded like it could be useful. (I saw no other 64s mentioned in combination with gcc.) But when I try to compile now, it says:

Code: Select all

$ gcc -mno-cygwin -O2 -s sdk.o mini2.c -o test.exe
gcc: The -mno-cygwin flag has been removed; use a mingw-targeted cross-compiler.
So I leave out the flag, and, and then it says:

Code: Select all

$ gcc -O2 -s sdk.o mini2.c -o test.exe
mini2.c:9:19: fatal error: conio.h: No such file or directory
compilation terminated.
So it does not know the headers anymore that are needed for a mingw compile.

What am I doing wrong? What does it mean by 'use a mingw-targeted cross compiler'? Isn't mingw64-x36_64-gcc exactly that? Must I invoke it with another command? Installing that mingw stuff completely messed up my old compiler, so I cannot even make 32-bit compiles anymore on that machine. :cry:
diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: How can I make 64-bit compiles with Cygwin?

Post by diep »

hgm wrote:I have a 64-bit computer now, and installed Cygwin on it. When I run GCC (version 3.4.4) on it in the usual way, it produces 32-bit binaries, however. So I tried to compile with the -m64 flag, and it says:

Code: Select all

$ gcc -mno-cygwin -m64 -O2 -s sdk.o mini2.c -o sdk-64.exe
mini2.c:1: sorry, unimplemented: 64-bit mode not compiled in
OK, so I went back to the Cygwin setup, and selected package mingw64-x86_64-gcc-core (and dependencies), which sounded like it could be useful. (I saw no other 64s mentioned in combination with gcc.) But when I try to compile now, it says:

Code: Select all

$ gcc -mno-cygwin -O2 -s sdk.o mini2.c -o test.exe
gcc: The -mno-cygwin flag has been removed; use a mingw-targeted cross-compiler.
So I leave out the flag, and, and then it says:

Code: Select all

$ gcc -O2 -s sdk.o mini2.c -o test.exe
mini2.c:9:19: fatal error: conio.h: No such file or directory
compilation terminated.
So it does not know the headers anymore that are needed for a mingw compile.

What am I doing wrong? What does it mean by 'use a mingw-targeted cross compiler'? Isn't mingw64-x36_64-gcc exactly that? Must I invoke it with another command? Installing that mingw stuff completely messed up my old compiler, so I cannot even make 32-bit compiles anymore on that machine. :cry:
Use mingw, not cygwin.

No problems with all that to compile Diep with.
I can compile then from the DOS command prompt in windoze
after setting a path and a few variables. So i'm not compiling from the $ prompt what cygwin is doing.

Cygwin always gave me big troubles everywhere doing that as it doesn't know the windows API then. So things go total wrong then (like multithreading and multiprocessing) whereas under mingw it goes ok.

Why don't you compile from linux though if you want to use GCC?
User avatar
hgm
Posts: 27701
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How can I make 64-bit compiles with Cygwin?

Post by hgm »

I need a Windows binary.
User avatar
hgm
Posts: 27701
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How can I make 64-bit compiles with Cygwin?

Post by hgm »

OK, I installed MinGW, and use it from the DOS prompt. But it still seems to produce 32-bit compiles. (I can run them on my old machines.)

What do I have to do to make it compile for x64?
User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 9:48 am

Re: How can I make 64-bit compiles with Cygwin?

Post by velmarin »

If you need something fast.
You can try this, Take a portable version.

If you do not like, delete it and it's over.


http://orwelldevcpp.blogspot.com.es/

Code: Select all

Download 
The setup which includes MinGW32 4.7.0 can be downloaded here (25MB).
The setup which includes TDM-GCC x64 4.6.1 can be downloaded here (35MB).
The setup which does not include a compiler can be downloaded here (2MB).
The portable version which includes MinGW32 4.7.0 can be downloaded here (15MB).
The portable version which includes TDM-GCC x64 4.6.1 can be downloaded here (25MB).
The portable version which does not include a compiler can be downloaded here (2MB).
Separate compilers can be downloaded here.
Lastly, the source code can be found here (1MB).
User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: How can I make 64-bit compiles with Cygwin?

Post by rvida »

hgm wrote:OK, I installed MinGW, and use it from the DOS prompt. But it still seems to produce 32-bit compiles. (I can run them on my old machines.)

What do I have to do to make it compile for x64?
You need to download & install a 64bit enabled version (obviously). I use this one:

http://sourceforge.net/projects/tdm-gcc ... e/download

It produces 64bit executables right out of the box. You can still build a 32bit binary if you specify -m32 command line parameter.
User avatar
Kirill Kryukov
Posts: 492
Joined: Sun Mar 19, 2006 4:12 am

Re: How can I make 64-bit compiles with Cygwin?

Post by Kirill Kryukov »

hgm wrote:I have a 64-bit computer now, and installed Cygwin on it. When I run GCC (version 3.4.4) on it in the usual way, it produces 32-bit binaries, however. So I tried to compile with the -m64 flag, and it says:

Code: Select all

$ gcc -mno-cygwin -m64 -O2 -s sdk.o mini2.c -o sdk-64.exe
mini2.c:1: sorry, unimplemented: 64-bit mode not compiled in
OK, so I went back to the Cygwin setup, and selected package mingw64-x86_64-gcc-core (and dependencies), which sounded like it could be useful. (I saw no other 64s mentioned in combination with gcc.) But when I try to compile now, it says:

Code: Select all

$ gcc -mno-cygwin -O2 -s sdk.o mini2.c -o test.exe
gcc: The -mno-cygwin flag has been removed; use a mingw-targeted cross-compiler.
So I leave out the flag, and, and then it says:

Code: Select all

$ gcc -O2 -s sdk.o mini2.c -o test.exe
mini2.c:9:19: fatal error: conio.h: No such file or directory
compilation terminated.
So it does not know the headers anymore that are needed for a mingw compile.

What am I doing wrong? What does it mean by 'use a mingw-targeted cross compiler'? Isn't mingw64-x36_64-gcc exactly that? Must I invoke it with another command?
Yes you can make 64-bit binaries with cygwin. Confusing part is that you have to use "x86_64-w64-mingw32-gcc.exe" instead of "gcc". I.e.:

Code: Select all

@set PATH=C:\cygwin\bin;%PATH%
@x86_64-w64-mingw32-gcc.exe -std=c89 -W -Wall -Wno-unused -O3 -fexpensive-optimizations -ffast-math -fopenmp -D__USE_MINGW_ANSI_STDIO=1 -s -o solver.exe src/solver.c
The only problem with this is that cygwin still ships ancient GCC 4.5.3, but otherwise it works fine.

EDIT:
hgm wrote:Installing that mingw stuff completely messed up my old compiler, so I cannot even make 32-bit compiles anymore on that machine. :cry:
Installing 64-bit mingw stuff through cygwin does not interfere at all with cygwin's normal 32-bit operation, including gcc. Of course if you use other compilers (like standalone mingw package), be careful about not putting everything into PATH, but only modify path when you are about to invoke particular compiler, like in the batch file I show above.
Tom Likens
Posts: 303
Joined: Sat Apr 28, 2012 6:18 pm
Location: Austin, TX

Re: How can I make 64-bit compiles with Cygwin?

Post by Tom Likens »

You need to download & install a 64bit enabled version (obviously). I use this one:

http://sourceforge.net/projects/tdm-gcc ... e/download

It produces 64bit executables right out of the box. You can still build a 32bit binary if you specify -m32 command line parameter.
Have you been able to successfully create a PGO-optimized executable with the Windows version of MingW?

--tom
Michel
Posts: 2271
Joined: Mon Sep 29, 2008 1:50 am

Re: How can I make 64-bit compiles with Cygwin?

Post by Michel »

In my experience it is far more convenient to make 64bit windows binaries by cross-compiling in Linux rather that doing it in Windows itself.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: How can I make 64-bit compiles with Cygwin?

Post by lucasart »

hgm wrote:I need a Windows binary.
Yes, and mingw can do that. For DsicoCheck, I've always produced my Win64 compiles with mingw, and they've always been correct, and at least as fast as the JA compiles. And the best part is: I don't even have Windows, so I never even tested them :-)

PS: As pointed out by Michel, it is far easier to compile the Windows binary using Linux than using DOS.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.