compiling StockFish

Discussion of chess software programming and technical issues.

Moderators: hgm, chrisw, Rebel

UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: compiling StockFish

Post by UncombedCoconut »

Sven Schüle wrote:UNIX shell trap ...
Depressingly, you are right!
What I find strangest is that both orders are equivalent if you are trying to funnel both file descriptors through a pipe rather than direct them to the same file. For instance:

Code: Select all

justinb@malibu:~$ sh -c 'echo Hello > /dev/stderr; echo world > /dev/stdout' 2>&1 > didJustinScrewUp; nl didJustinScrewUp
Hello
     1	world
justinb@malibu:~$ sh -c 'echo Hello > /dev/stderr; echo world > /dev/stdout' 2>&1 | nl
     1	Hello
     2	world
This strengthens my wish that before I die I'll see a truly useful "legacy" system which doesn't preserve crazy bugs for compatibility's sake. But at least I can now stump my friends with puzzles about when "|cat" is not a no-op. :)
lucasart
Posts: 3238
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: compiling StockFish

Post by lucasart »

UncombedCoconut wrote: And an attempt to explain make:
Stockfish's Makefile includes a lot of code to decide on compiler flags. Yet its core job is simple: build each object after its dependencies. It differs as follows from a "g++ [flags] *.cpp" command:
* It compiles the source files, separately, until it has up-to-date object code for each file. It passes "-c" to g++, which tells it to output an (incomplete) object file (named by the "-o filename.o" flag).
* Once the object files are ready, it passes all of them to g++ to be linked. The "-o stockfish" flag tells g++ to create an output file named "stockfish" in the current directory (/home/lucas/Downloads/src)

Because make compiles your source files separately, and only when they change, it is an enormous time-saver for developers of projects with many source files. As such, I strongly suggest that you use it in your own project. You will quickly recover the time invested in learning it. :)

HTH
Ah... you guys are probably right! There I was, just wanting to program a chess engine for fun, and now I need to learn make, git, and the shell basics that I still lack (redirecting stderr for one).
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: compiling StockFish

Post by UncombedCoconut »

I suppose you could alternatively tie your engine's build process to a specific IDE. :)
lucasart
Posts: 3238
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: compiling StockFish

Post by lucasart »

UncombedCoconut wrote:I suppose you could alternatively tie your engine's build process to a specific IDE. :)
Oh no, I want to make an UCI one. Besides, I don't want to go through the pain of doing a GUI. What I need to do is an UCI interface that allows matches between engines in an industralised way. I can't find any good UCI interface on Linux, they're all Internet Chess oriented not Computer chess oriented if you like.

All I want is a simple command line tool, that takes 2 engines, does matches between them and writes a PGN out of it. Does anyone know if such a program exists (on Linux) ?
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: compiling StockFish

Post by zamar »

lucasart wrote:
UncombedCoconut wrote:I suppose you could alternatively tie your engine's build process to a specific IDE. :)
Oh no, I want to make an UCI one. Besides, I don't want to go through the pain of doing a GUI. What I need to do is an UCI interface that allows matches between engines in an industralised way. I can't find any good UCI interface on Linux, they're all Internet Chess oriented not Computer chess oriented if you like.

All I want is a simple command line tool, that takes 2 engines, does matches between them and writes a PGN out of it. Does anyone know if such a program exists (on Linux) ?
Cutechess-cli
Xboard+polyglot
Joona Kiiski
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: compiling StockFish

Post by UncombedCoconut »

lucasart wrote:
UncombedCoconut wrote:I suppose you could alternatively tie your engine's build process to a specific IDE. :)
Oh no, I want to make an UCI one. Besides, I don't want to go through the pain of doing a GUI.
IDE doesn't mean GUI; it would just let you create a "project" rather than a makefile. The distinction would be how you compile; the program would be identical.
What I need to do is an UCI interface that allows matches between engines in an industralised way. I can't find any good UCI interface on Linux, they're all Internet Chess oriented not Computer chess oriented if you like.

All I want is a simple command line tool, that takes 2 engines, does matches between them and writes a PGN out of it. Does anyone know if such a program exists (on Linux) ?
cutechess-cli by Ilari Pihlajisto. The docs will take some time to parse, but it's very powerful. xboard with an adapter is similar. [Edit: Joona wins :)]
Airton
Posts: 6
Joined: Fri Oct 19, 2012 7:18 pm
Location: Belo Horizonte, Brazil

Re: compiling StockFish

Post by Airton »

Error while compiling latest stockfish versions "/bin/sh: ../scripts/net.sh: No such file or directory". Some clue? A compiler installation trouble? A makefile trick?
User avatar
Ras
Posts: 2650
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: compiling StockFish

Post by Ras »

Airton wrote: Sat Nov 02, 2024 7:28 pmError while compiling latest stockfish versions "/bin/sh: ../scripts/net.sh: No such file or directory". Some clue? A compiler installation trouble? A makefile trick?
Maybe you only updated the src directory on your local end? Because in the scripts directory, the SF17 release did not contain a net.sh script, and the makefile did not call that script. With current dev, there is scripts/net.sh, and that is called from the makefile. You should also update the scripts directory on your local end.
Rasmus Althoff
https://www.ct800.net
Airton
Posts: 6
Joined: Fri Oct 19, 2012 7:18 pm
Location: Belo Horizonte, Brazil

Re: compiling StockFish

Post by Airton »

Thank you so much. A makefile detail.
chessica
Posts: 865
Joined: Thu Aug 11, 2022 11:30 pm
Full name: Esmeralda Pinto

Re: compiling StockFish

Post by chessica »

lucasart wrote: Sun Dec 12, 2010 11:49 am Hello
I am trying to compile StockFish 1.9.1, but I get tons of errors.
I am running Linux (Ubuntu 10.10 64bit) and a recent version of g++ (4.4.5), and typing:
make profile-build ARCH=x86-64
Among the errors I get, g++ finds #include nested too deeply. For example position.h is including itself! And there's no #pragma once or #ifdef to stop the infinite self inclusion of the file, so the error seems logical to me...
I get the same errors if I just compile the simply way:
g++ -O3 -o ./sf *.cpp
Has anyone managed to compile it with gcc ?
Thank you
Oha, I'll take a different route.

Here Linux MX, download Stockfish, open the Linux terminal, gcc is automatically preinstalled,

$ gcc --version
gcc (Debian 12.2.0) 12.2.0

Then go to the Downloads folder and unpack the Stockfish.
Navigate to the directory where the Makefile is located.
make
Now wait... until steps 1,2,3 and 4 are completed
open the file manager: Linux - Thunar, in the src folder is then located
stockfish without extension (exe)!
You then drag this file, without an extension, to the desktop
But you can't just start it there with a double click! tricky!


Right-click on the desktop and click on “Create Starter” in the menu that appears.

enter any name, specify directories,
...191-ja/src/stockfish
...191-yes/src

Check the box for execute in the terminal, click create

complete


I just did this and it works. :-)