what is the best free compiler to use?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Uri Blass
Posts: 10281
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

what is the best free compiler to use?

Post by Uri Blass »

I consider going back to do some programming in C for chess and I wonder what is the best new free compiler for windows.

I see an option to download visual studio but there are 3 options community 2017 professional 2017 and enterprice 2017 and
I do not know what is the difference.

https://visualstudio.microsoft.com/vs/f ... cplusplus/
chrisw
Posts: 4315
Joined: Tue Apr 03, 2012 4:28 pm

Re: what is the best free compiler to use?

Post by chrisw »

They are not all free if I remember correct.
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: what is the best free compiler to use?

Post by cdani »

I use the free community version. The others are not.
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: what is the best free compiler to use?

Post by Joost Buijs »

I use both the professional (which is not free) and the community (which is free), the difference between the two is negligible. The quality of the MSVC compiler improved a lot over the last 2 years, the performance almost equals the performance of the Intel compiler. In my latest programs I use a lot of C++14 and C++17 template meta programming constructs and haven't found any problems with it yet.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: what is the best free compiler to use?

Post by Ras »

GCC with MingW is also a free option: https://sourceforge.net/projects/mingw-w64/
Rasmus Althoff
https://www.ct800.net
Dann Corbit
Posts: 12539
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: what is the best free compiler to use?

Post by Dann Corbit »

Expanding on GCC + MINGW + MSYS2 option:

You can also get CODE::BLOCKS code editor, which allows you to debug like the MSVC version in both Windows and Linux.
https://www.msys2.org/
http://www.codeblocks.org/

On the Microsoft Compiler, only the community version is free.
The Enterprise version has lots of nice things that the community version is missing, but it costs an arm and a leg.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: what is the best free compiler to use?

Post by phhnguyen »

Try gcc, it’s totally free and definitely it’s not bad.

Recently I compared my engine compiled by gcc (with Cygwin) and VS (2018 community version). The result surprised me much: the one compiled by gcc was 10 - 20% faster than the one compiled by VS, a significant margin and not as I supposed. Probably I work mainly on macOs, using gcc, thus I didn’t twist the code and settings enough for speeding up with Windows/VS. But who knows, it may happen the same for your code!
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
odomobo
Posts: 96
Joined: Fri Jul 06, 2018 1:09 am
Location: Chicago, IL
Full name: Josh Odom

Re: what is the best free compiler to use?

Post by odomobo »

phhnguyen wrote: Wed Oct 03, 2018 3:54 am Probably I work mainly on macOs, using gcc, thus I didn’t twist the code and settings enough for speeding up with Windows/VS.
In my experience, if you build in release mode for x64 (if you have a 64-bit processor) will get you a pretty optimal build. I'm lucky if tweaking the settings from there will give me any performance improvement. By default, it enables some pretty aggressive optimizations, including link-time optimization.
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: what is the best free compiler to use?

Post by Joost Buijs »

odomobo wrote: Wed Oct 03, 2018 6:48 am
phhnguyen wrote: Wed Oct 03, 2018 3:54 am Probably I work mainly on macOs, using gcc, thus I didn’t twist the code and settings enough for speeding up with Windows/VS.
In my experience, if you build in release mode for x64 (if you have a 64-bit processor) will get you a pretty optimal build. I'm lucky if tweaking the settings from there will give me any performance improvement. By default, it enables some pretty aggressive optimizations, including link-time optimization.
With VS I usually get the best result when I enable AVX2 code generation, which most CPUs support nowadays, another thing is to disable the 'Security Check' in the generated code which also gains a few percent in speed. I'm totally happy with VS, it compiles very fast especially when you enable MP compilation, totally rebuilding my engine with VS takes about 5 sec. on my 10 core PC, and that is with the project on an old hard drive, on a SSD it will compile even faster.

It is possible that GCC generates somewhat faster code, but the difference is so small that it is negligible in practice, in my opinion GCC is rather cumbersome to use, especially on Windows, for development I would go for VS any day.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: what is the best free compiler to use?

Post by Sven »

Joost Buijs wrote: Wed Oct 03, 2018 9:15 am
odomobo wrote: Wed Oct 03, 2018 6:48 am
phhnguyen wrote: Wed Oct 03, 2018 3:54 am Probably I work mainly on macOs, using gcc, thus I didn’t twist the code and settings enough for speeding up with Windows/VS.
In my experience, if you build in release mode for x64 (if you have a 64-bit processor) will get you a pretty optimal build. I'm lucky if tweaking the settings from there will give me any performance improvement. By default, it enables some pretty aggressive optimizations, including link-time optimization.
With VS I usually get the best result when I enable AVX2 code generation, which most CPUs support nowadays, another thing is to disable the 'Security Check' in the generated code which also gains a few percent in speed. I'm totally happy with VS, it compiles very fast especially when you enable MP compilation, totally rebuilding my engine with VS takes about 5 sec. on my 10 core PC, and that is with the project on an old hard drive, on a SSD it will compile even faster.

It is possible that GCC generates somewhat faster code, but the difference is so small that it is negligible in practice, in my opinion GCC is rather cumbersome to use, especially on Windows, for development I would go for VS any day.
For my engine Jumbo GCC (even in older versions) has always created around 30-40% faster code than VS (even with VS2017 community). I talk about the 64-bit build of Jumbo's bitboard variant.
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)