How to compile from Source Codes and the Tools

General discussion about computer chess...
User avatar
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: How to compile from Source Codes and the Tools

Post by kingliveson » Fri Jan 21, 2011 1:46 am

Prima wrote:Kingliveson, Peter C, Jeremy Berstein, and BB+,

I appreciate all these inputs. Much as I admire programming in itself, I want to learn how to compile a Windows executive file (or chess engine) from any given source code using the Intel 30-day trial version or any free compiler that is equally compatible with Windows/Intel PC platform.

I have come across few forums where an individual asks how to compile from source codes and the replies given suggests that executive file compiles can be compiled from source codes using the 2 tools I mentioned in my original post;
1. Microsoft Visual Studio 2010 Professional trail web installer and
2. Intel 30-day free trial Compiler

Can these 2 tools accomplish my task of attempting to compile chess engines? If yes, do I just place the main source code within the Intel compiler and it will automatically compile a chess engine for me?

Also from the Intel Compile download page excerpt I pasted in my original post, what sub-components,for the Intel compiler, should I select to be included in the main Intel compiler before the final download? Would it be better if I selected all compiler sub-components? Thanks immensely for any feedback.

Kingliveson, I'll look into the CLI. Thank you all.
Yes, the following tools are sufficient, though Visual Studio alone should be enough. The reason for suggesting you learn a language, preferable C, is because most chess programs are either written in C or C++ (an extension of C). And also, by the time you write your first program, say 'Hello World,' you have to compile it -- in essence, two birds with one stone; you learn basic C and how to compile from source.
PAWN : Knight >> Bishop >> Rook >>Queen

Peter C
Posts: 154
Joined: Thu Jun 10, 2010 3:12 am
Real Name: Peter C

Re: How to compile from Source Codes and the Tools

Post by Peter C » Fri Jan 21, 2011 9:03 pm

Jeremy Bernstein wrote:
Peter C wrote:If you want him to learn "the core of programming" you might as well have him learn assembly. :roll:

C is ancient. It doesn't support object oriented programming, it doesn't support functional programming (aside from function pointers, but those hardly count), and you have to manage your own memory. And don't tell him to learn C++, that takes years to learn.

He could easily learn Python in a month. He could be writing useful things in Python in well under a month. The only problem is that he has a C compiler. :P So, yeah, I guess he should learn C.

Peter
Just to confuse matters further, if you want to learn something C-like that you can use immediately for useful stuff, learn Javascript. You can run it in your browser, build Flash and DashBoard with it, it looks like C, doesn't have silly whitespace rules like Python and will prepare you for nearly any kind of other programming you move on to.
JavaScript has that crazy prototypal inheritance disguised to look like Java, implicit global variables, weird semicolon insertion, no real standard library, and a whole host of other problems.
It looks like C, but it doesn't act like C. It's more like Lisp, and really is a functional (as opposed to procedural like C) language.

Python's whitespace rules really aren't that weird when you think about it. You indent your lines anyway, right? And it avoids having all those messy braces and semicolons everywhere.

Prima, if you want to compile chess programs and stuff you should learn C or C++ (which is what most chess programs are written in). Instead of those trials I can highly recommend MinGW, which ports the GCC compiler and some other tools to Windows. The only real limitation is that you won't be able to make 64-bit compiles, although somebody mentioned in my Stockfish GTB thread that there is a 64-bit version. I don't know if it works though. :P

Peter

Ron Murawski
Posts: 11
Joined: Thu Jun 10, 2010 6:04 am

Re: How to compile from Source Codes and the Tools

Post by Ron Murawski » Fri Jan 21, 2011 11:34 pm

Peter C wrote:I can highly recommend MinGW, which ports the GCC compiler and some other tools to Windows. The only real limitation is that you won't be able to make 64-bit compiles, although somebody mentioned in my Stockfish GTB thread that there is a 64-bit version. I don't know if it works though. :P

Peter
I am hosting WPG System64 which uses gcc. It can compile 32 or 64-bit apps. It works very well.
http://www.horizonchess.com/wpg64/

Ron

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: How to compile from Source Codes and the Tools

Post by Prima » Sun Jan 23, 2011 7:59 am

Thanks everybody for the suggestions and help.

The entire Saturday was a waste as I could not finish everything or configure the compiler. I guess after installing the Intel 30-day trial compiler, I'm still lost as to the next step in order to compile a windows executive file from an open source engine. I Googled extensively but most tutorials do not provide the same settings as seen on my PC. From my Windows Start menu, I have;
All Programs/Intel Parallel Studio XE 2011/:
Parallel Studio XE 2011 with VS2010/:
Command Prompt
Documentation
Getting Started
Intel Compiler XE


The 'Getting Started' seems not helpful to me, unless I'm missing something here. Any further instruction here would is appreciated. Thanks.

Ron Murawski, I downloaded the Ming64-bit compiler along with the MingW64 1.99 patcher provided from your link/site. Thanks. I may have to look into that as well.

User avatar
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: How to compile from Source Codes and the Tools

Post by kingliveson » Mon Jan 24, 2011 6:06 am

Prima wrote:I need help/instructions [...]. [...]. I have downloaded the Microsoft Visual Studio 2010 Professional trail web installer. With the download of the intel compiler [...]

[...] I'm interested in compiling mainly 64-bits. [...]
Stockfish (version 2.01) is one of the easiest open-source chess programs to build, and will be used in the example. I extracted the archive, and renamed the src directory to Stockfish201.

1. With Visual Studio running...Click the File menu , select New, and then Project...

2. Expand Visual C++ template and select General. Browse to and chose the directory that has the source files, then type the project Name, and click Empty Project.

3. Right click the newly created project under Solutions Explorer, and select Add, and Existing Items...

4. Browse to the directory containing the source files (not solutions directory). Select all the files and click Add. All the files can be selected by simply clicking on the first file, scroll down, with the Shift key pressed, click on the last file.

5. To build x64 executables, select Configuration Manager from the Solutions Platforms drop menu.

6. Choose New from the Active solution platform.

7. Select x64, click Ok and the Close.

8. Select Release (default is Debug) from Solution Configuration drop menu.

9. To build the source, select from Build menu, Build Solution.

10. Upon successful compilation, your new executable should be available in the solutions directory (...\x64\Release\Stockfish201.exe for example).

11. To use Intel Compiler, select your Intel version from Project menu, choose Use Intel C++, and click Ok.

You can edit source files by expanding Source File filter, and double clicking a file. There are also optimizations that can be configured under project property...Google is very resourceful.

For Linux, you open terminal in the source directory containing Makefile and run make. :D
Attachments
20110123_new_project_s01.jpg
Step 01
20110123_empty_project_s02.jpg
Step 02
20110123_add_existing_item_s03.jpg
Step 03
20110123_add_existing_item_source_s04.jpg
Step 04
20110123_solutions_platform_s05.jpg
Step 05
20110123_solutions_platform_new_s06.jpg
Step 06
20110123_solutions_platform_x64_s07.jpg
Step 07
20110123_solutions_config_s08.jpg
Step 08
20110123_build_solutions_s09.jpg
Step 09
20110123_build_solutions_succeed_s10.jpg
Step 10
20110123_icc_s11.jpg
Step 11
20110123_icc_s12.jpg
Step 12
20110123_solutions_explorer_source_s13.jpg
Solution Explorer
PAWN : Knight >> Bishop >> Rook >>Queen

BB+
Posts: 1484
Joined: Thu Jun 10, 2010 4:26 am

Re: How to compile from Source Codes and the Tools

Post by BB+ » Mon Jan 24, 2011 6:29 am

For Linux, you open terminal in the source directory containing Makefile and run make. :D
Umm, with Stockfish at least, you need to append the "ARCH=..." part to the "make" command. :!:

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: How to compile from Source Codes and the Tools

Post by Prima » Mon Jan 24, 2011 7:26 pm

Thanks, Kingliveson, for your time and the tutorials. I'll try it out. Thanks BB+ for your input.

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: How to compile from Source Codes and the Tools

Post by Prima » Tue Jan 25, 2011 7:12 am

Kingliveson,

A big 'thank you' for the compile tutoring. I really appreciate it but at a lost for words to express my gratitude to you. I finally made my compile of Tinapa 1.01 for 64-bit, found here http://www.open-chess.org/viewtopic.php ... 9210#p9210

Next, I'll try to compile a 64-bit ComStock 2.0.1 and hopefully Stockfish 2.0.1GTB.

Thanks also to others who gave pointers.

User avatar
Uly
Posts: 838
Joined: Thu Jun 10, 2010 5:33 am

Re: How to compile from Source Codes and the Tools

Post by Uly » Sun Jan 30, 2011 2:22 am

Hi, could there be given instructions on how to make a 64bit compile with a minimalistic install? Microsoft Visual Studio 2010 seems to be 7GB and that seems excessive.

I recall I used some small program for my custom TSCP compiles, but I don't remember what since it was several years ago.

Ron Murawski
Posts: 11
Joined: Thu Jun 10, 2010 6:04 am

Re: How to compile from Source Codes and the Tools

Post by Ron Murawski » Sun Jan 30, 2011 6:50 pm

Uly wrote: I recall I used some small program for my custom TSCP compiles, but I don't remember what since it was several years ago.
One of these maybe?


MinGW-w64 -- a 32/64-bit Build and Development Environment for Windows (CygWin) with minimal toolchain. No GUI IDE. Open-source. Contains GCC
http://sourceforge.net/projects/mingw-w64/

Open Watcom -- Open Watcom 32/64-bit C/C++ compiler with IDE + tools for Windows. Open-source.
http://www.openwatcom.org/

MinGW -- 32-bit builds for Windows. No GUI IDE. Open-source. Contains GCC
http://www.mingw.org/

Digital Mars -- C/C++ and D 32-bit compilers for Windows. Free. Some Free GUI IDEs support the D language.
http://www.digitalmars.com/

LCC-Win32 -- LCC C compiler with IDE + tools for Windows. Free.
http://www.cs.virginia.edu/~lcc-win32/


Ron

Post Reply