win64 compile under Linux ?

Discussion of chess software programming and technical issues.

Moderator: Ras

lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

win64 compile under Linux ?

Post by lucasart »

Hello

Is it possible to create a win64 executable with GCC under Linux ?

Thank you
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: win64 compile under Linux ?

Post by michiguel »

lucasart wrote:Hello

Is it possible to create a win64 executable with GCC under Linux ?

Thank you
Yes, this is what I use:
http://mingw-w64.sourceforge.net/

Miguel
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: win64 compile under Linux ?

Post by lucasart »

michiguel wrote:
lucasart wrote:Hello

Is it possible to create a win64 executable with GCC under Linux ?

Thank you
Yes, this is what I use:
http://mingw-w64.sourceforge.net/

Miguel
Thanks. Just downloaded it. I don't know if I dl the right file as there are so many of them, and there's no explanation as to which i should dl. Anyway unpacked it and here's what I have

Code: Select all

drwx------ 8 lucas lucas 4096 2011-07-20 11:43 ./
drwxr-xr-x 4 lucas lucas 4096 2011-07-28 19:04 ../
drwx------ 2 lucas lucas 4096 2011-07-20 11:54 bin/
drwx------ 2 lucas lucas 4096 2011-07-20 11:28 include/
drwx------ 3 lucas lucas 4096 2011-07-20 11:54 lib/
drwx------ 3 lucas lucas 4096 2011-07-20 11:43 libexec/
lrwxrwxrwx 1 lucas lucas   18 2011-07-20 11:28 mingw -> x86_64-w64-mingw32/
-rw------- 1 lucas lucas    0 2011-07-20 11:28 .root.init.marker
drwx------ 6 lucas lucas 4096 2011-07-20 11:54 share/
drwx------ 6 lucas lucas 4096 2011-07-20 11:46 x86_64-w64-mingw32/
So basically, where' my gcc, and with what flags should I use it to produce a win64 exe ?
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: win64 compile under Linux ?

Post by Sven »

lucasart wrote:
michiguel wrote:
lucasart wrote:Hello

Is it possible to create a win64 executable with GCC under Linux ?

Thank you
Yes, this is what I use:
http://mingw-w64.sourceforge.net/

Miguel
Thanks. Just downloaded it. I don't know if I dl the right file as there are so many of them, and there's no explanation as to which i should dl.
I'd guess "mingw-w64-bin_i686-linux_20110720.tar.bz2" should be the right file (newest of the builds for Linux platform in the "automated builds" folder). From the dates you posted it seems you took the right one.
The explanation you were seeking can be found by clicking on "What do I download?" on the left side of the Overview page.
lucasart wrote:So basically, where' my gcc,
EDIT: in the "bin" folder ...
You have a cross-compiler. Usually cross-platform binaries have very long names, presumably "x86_64-w64-mingw32-gcc" in this case (see last sentence on "Overview" page). The name "gcc" is used for the native compiler version (compile on platform X for target platform X).
lucasart wrote:and with what flags should I use it to produce a win64 exe ?
According to the Documentation wiki you'll just need to put the path of the .../bin subfolder that contains the cross-compiler binary into your PATH variable so that the tool finds everything else on its own. Additional flags should not be necessary. But you'll have to try it.

Sven
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: win64 compile under Linux ?

Post by michiguel »

Sven Schüle wrote:
lucasart wrote:
michiguel wrote:
lucasart wrote:Hello

Is it possible to create a win64 executable with GCC under Linux ?

Thank you
Yes, this is what I use:
http://mingw-w64.sourceforge.net/

Miguel
Thanks. Just downloaded it. I don't know if I dl the right file as there are so many of them, and there's no explanation as to which i should dl.
I'd guess "mingw-w64-bin_i686-linux_20110720.tar.bz2" should be the right file (newest of the builds for Linux platform in the "automated builds" folder). From the dates you posted it seems you took the right one.
The explanation you were seeking can be found by clicking on "What do I download?" on the left side of the Overview page.
lucasart wrote:So basically, where' my gcc,
EDIT: in the "bin" folder ...
You have a cross-compiler. Usually cross-platform binaries have very long names, presumably "x86_64-w64-mingw32-gcc" in this case (see last sentence on "Overview" page). The name "gcc" is used for the native compiler version (compile on platform X for target platform X).
lucasart wrote:and with what flags should I use it to produce a win64 exe ?
According to the Documentation wiki you'll just need to put the path of the .../bin subfolder that contains the cross-compiler binary into your PATH variable so that the tool finds everything else on its own. Additional flags should not be necessary. But you'll have to try it.

Sven
I hope this example helps Lucas. For instance, this would compile my program gaviota.

Miguel

Code: Select all

#!/bin/sh

PATH=$PATH:/home/miguel/mingw-w64/bin

x86_64-w64-mingw32-gcc -I sysport/ -I compression/ -I compression/huffman/ -I compression/liblzf/ -I compression/zlib/ -I compression/lzma/ -D Z_PREFIX -D GTB_SHARE -D NDEBUG -D MINGW -lm -Wwrite-strings -Wconversion -Wshadow -Wparentheses -Wlogical-op -Wunused -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement -W -Wall -Wextra -O2  -o gaviota bb_intrn.c bb_pin.c book.c build.c search.c data.c debuggin.c egdb.c eng.c eval.c evalp.c evp.c fitev.c follow.c foption.c generate.c glb_cntr.c hash.c ini.c killer.c k-pst.c logout.c main.c makemove.c mdfy.c minipos.c move.c myassert.c mystr.c output.c pgnread.c pool.c position.c rand.c san2mv.c scsheet.c see.c sqlist.c strchess.c test.c timer.c tra.c validate.c variatio.c xbio.c xboard.c str64.c nc_hash.c gtb-att.c gtb-probe.c gtb-dec.c gtb-build.c gtb-test.c gtb-print.c gtb-glue.c att-new.c proginfo.c sysport/sysport.c compression/wrap.c compression/huffman/hzip.c compression/lzma/LzmaEnc.c compression/lzma/LzmaDec.c compression/lzma/Alloc.c compression/lzma/LzFind.c compression/lzma/Lzma86Enc.c compression/lzma/Lzma86Dec.c compression/lzma/Bra86.c compression/zlib/zcompress.c compression/zlib/uncompr.c compression/zlib/inflate.c compression/zlib/deflate.c compression/zlib/adler32.c compression/zlib/crc32.c compression/zlib/infback.c compression/zlib/inffast.c compression/zlib/inftrees.c compression/zlib/trees.c compression/zlib/zutil.c compression/liblzf/lzf_c.c compression/liblzf/lzf_d.c
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: win64 compile under Linux ?

Post by lucasart »

michiguel wrote: I hope this example helps Lucas. For instance, this would compile my program gaviota.

Miguel

Code: Select all

#!/bin/sh

PATH=$PATH:/home/miguel/mingw-w64/bin

x86_64-w64-mingw32-gcc -I sysport/ -I compression/ -I compression/huffman/ -I compression/liblzf/ -I compression/zlib/ -I compression/lzma/ -D Z_PREFIX -D GTB_SHARE -D NDEBUG -D MINGW -lm -Wwrite-strings -Wconversion -Wshadow -Wparentheses -Wlogical-op -Wunused -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement -W -Wall -Wextra -O2  -o gaviota bb_intrn.c bb_pin.c book.c build.c search.c data.c debuggin.c egdb.c eng.c eval.c evalp.c evp.c fitev.c follow.c foption.c generate.c glb_cntr.c hash.c ini.c killer.c k-pst.c logout.c main.c makemove.c mdfy.c minipos.c move.c myassert.c mystr.c output.c pgnread.c pool.c position.c rand.c san2mv.c scsheet.c see.c sqlist.c strchess.c test.c timer.c tra.c validate.c variatio.c xbio.c xboard.c str64.c nc_hash.c gtb-att.c gtb-probe.c gtb-dec.c gtb-build.c gtb-test.c gtb-print.c gtb-glue.c att-new.c proginfo.c sysport/sysport.c compression/wrap.c compression/huffman/hzip.c compression/lzma/LzmaEnc.c compression/lzma/LzmaDec.c compression/lzma/Alloc.c compression/lzma/LzFind.c compression/lzma/Lzma86Enc.c compression/lzma/Lzma86Dec.c compression/lzma/Bra86.c compression/zlib/zcompress.c compression/zlib/uncompr.c compression/zlib/inflate.c compression/zlib/deflate.c compression/zlib/adler32.c compression/zlib/crc32.c compression/zlib/infback.c compression/zlib/inffast.c compression/zlib/inftrees.c compression/zlib/trees.c compression/zlib/zutil.c compression/liblzf/lzf_c.c compression/liblzf/lzf_d.c
Thank you. Very helpful indeed !
I managed to compile without errors as follows:

Code: Select all

lucas@lucas-desktop:~/Downloads/mingw/bin$ ./x86_64-w64-mingw32-gcc -o ~/DoubleCheck.exe -std=c99 -DNDEBUG -O3 ~/.codelite/Chess/DoubleCheck/*.c
But I don't have windows to test it, and Wine only works for 64 bits :-S
I wonder whether I need all your -I commands, and whether the exe file I've created would execute correctly in Windows without any external dependancies (like some *.dll)
Any idea ?
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: win64 compile under Linux ?

Post by michiguel »

lucasart wrote:
michiguel wrote: I hope this example helps Lucas. For instance, this would compile my program gaviota.

Miguel

Code: Select all

#!/bin/sh

PATH=$PATH:/home/miguel/mingw-w64/bin

x86_64-w64-mingw32-gcc -I sysport/ -I compression/ -I compression/huffman/ -I compression/liblzf/ -I compression/zlib/ -I compression/lzma/ -D Z_PREFIX -D GTB_SHARE -D NDEBUG -D MINGW -lm -Wwrite-strings -Wconversion -Wshadow -Wparentheses -Wlogical-op -Wunused -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement -W -Wall -Wextra -O2  -o gaviota bb_intrn.c bb_pin.c book.c build.c search.c data.c debuggin.c egdb.c eng.c eval.c evalp.c evp.c fitev.c follow.c foption.c generate.c glb_cntr.c hash.c ini.c killer.c k-pst.c logout.c main.c makemove.c mdfy.c minipos.c move.c myassert.c mystr.c output.c pgnread.c pool.c position.c rand.c san2mv.c scsheet.c see.c sqlist.c strchess.c test.c timer.c tra.c validate.c variatio.c xbio.c xboard.c str64.c nc_hash.c gtb-att.c gtb-probe.c gtb-dec.c gtb-build.c gtb-test.c gtb-print.c gtb-glue.c att-new.c proginfo.c sysport/sysport.c compression/wrap.c compression/huffman/hzip.c compression/lzma/LzmaEnc.c compression/lzma/LzmaDec.c compression/lzma/Alloc.c compression/lzma/LzFind.c compression/lzma/Lzma86Enc.c compression/lzma/Lzma86Dec.c compression/lzma/Bra86.c compression/zlib/zcompress.c compression/zlib/uncompr.c compression/zlib/inflate.c compression/zlib/deflate.c compression/zlib/adler32.c compression/zlib/crc32.c compression/zlib/infback.c compression/zlib/inffast.c compression/zlib/inftrees.c compression/zlib/trees.c compression/zlib/zutil.c compression/liblzf/lzf_c.c compression/liblzf/lzf_d.c
Thank you. Very helpful indeed !
I managed to compile without errors as follows:

Code: Select all

lucas@lucas-desktop:~/Downloads/mingw/bin$ ./x86_64-w64-mingw32-gcc -o ~/DoubleCheck.exe -std=c99 -DNDEBUG -O3 ~/.codelite/Chess/DoubleCheck/*.c
But I don't have windows to test it, and Wine only works for 64 bits :-S
I wonder whether I need all your -I commands, and whether the exe file I've created would execute correctly in Windows without any external dependancies (like some *.dll)
Any idea ?
the -I in my example are necessary for including tablebase probing code. You won't need any .dll or anything like that. The only way to make sure it works is in a windows system, but it should work.

Miguel
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: win64 compile under Linux ?

Post by lucasart »

michiguel wrote: the -I in my example are necessary for including tablebase probing code. You won't need any .dll or anything like that. The only way to make sure it works is in a windows system, but it should work.
Miguel
Thank you.
I've sent it to Leo from WBEC, and it seems to work on Windows :-)
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: win64 compile under Linux ?

Post by Don »

Sven Schüle wrote:
lucasart wrote:
michiguel wrote:
lucasart wrote:Hello

Is it possible to create a win64 executable with GCC under Linux ?

Thank you
Yes, this is what I use:
http://mingw-w64.sourceforge.net/

Miguel
Thanks. Just downloaded it. I don't know if I dl the right file as there are so many of them, and there's no explanation as to which i should dl.
I'd guess "mingw-w64-bin_i686-linux_20110720.tar.bz2" should be the right file (newest of the builds for Linux platform in the "automated builds" folder). From the dates you posted it seems you took the right one.
The explanation you were seeking can be found by clicking on "What do I download?" on the left side of the Overview page.
lucasart wrote:So basically, where' my gcc,
EDIT: in the "bin" folder ...
You have a cross-compiler. Usually cross-platform binaries have very long names, presumably "x86_64-w64-mingw32-gcc" in this case (see last sentence on "Overview" page). The name "gcc" is used for the native compiler version (compile on platform X for target platform X).
lucasart wrote:and with what flags should I use it to produce a win64 exe ?
According to the Documentation wiki you'll just need to put the path of the .../bin subfolder that contains the cross-compiler binary into your PATH variable so that the tool finds everything else on its own. Additional flags should not be necessary. But you'll have to try it.

Sven
You can also PGO compile it. I'm quite surprised that it works but it does. Basically do the PGO on Linux using 64 bit gcc for linux and save the profile data. Then compile it on the cross compiler using the same profile. You executable will be noticeably faster.