syzygy1 / Cfish

C port of Stockfish
GNU General Public License v3.0
137 stars 58 forks source link

Cannot compile on my iMac #100

Closed nguyenpham closed 5 years ago

nguyenpham commented 5 years ago

Error message:

Nguyens-iMac:src nguyenpham$ make build ARCH=x86-64 COMP=clang

Config:
debug: 'no'
optimize: 'yes'
arch: 'x86_64'
bits: '64'
prefetch: 'yes'
popcnt: 'no'
sse: 'yes'
pext: 'no'

Flags:
CC: clang
CFLAGS: -Wall -std=c11  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -m64  -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native -DNUMA
LDFLAGS:  -lm -m64 -arch x86_64 -mmacosx-version-min=10.9 -lpthread

Testing config sanity. If this fails, try 'make help' ...

/Library/Developer/CommandLineTools/usr/bin/make ARCH=x86-64 COMP=clang all
clang -Wall -std=c11  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -m64  -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native -DNUMA   -c -o benchmark.o benchmark.c
In file included from benchmark.c:29:
In file included from ./settings.h:4:
./numa.h:7:10: error: 'numa.h' file not found with <angled> include; use "quotes" instead
#include <numa.h>
         ^~~~~~~~
         "numa.h"
1 error generated.
make[1]: *** [benchmark.o] Error 1
make: *** [build] Error 2
MichaelB7 commented 5 years ago

Remove -DNUMA flag , not supported by macOS.

nguyenpham commented 5 years ago

Thanks for your help.

It is hard for me since I am new to make. I tried but still got another error as below. Can you or someone give command lines to compile in MacOs? Thanks


Nguyens-iMac:src nguyenpham$ make build ARCH=x86-64 numa=no

Config:
debug: 'no'
optimize: 'yes'
arch: 'x86_64'
bits: '64'
prefetch: 'yes'
popcnt: 'no'
sse: 'yes'
pext: 'no'

Flags:
CC: gcc
CFLAGS: -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native
LDFLAGS:  -lm -m64 -arch x86_64 -mmacosx-version-min=10.9 -lpthread

Testing config sanity. If this fails, try 'make help' ...

/Library/Developer/CommandLineTools/usr/bin/make ARCH=x86-64 COMP=gcc all
gcc -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native   -c -o benchmark.o benchmark.c
gcc -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native   -c -o bitbase.o bitbase.c
gcc -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native   -c -o bitboard.o bitboard.c
gcc -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native   -c -o endgame.o endgame.c
gcc -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native   -c -o evaluate.o evaluate.c
gcc -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native   -c -o main.o main.c
gcc -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native   -c -o material.o material.c
gcc -Wall -std=c11  -pedantic -Wextra -Wshadow -m64 -D_POSIX_C_SOURCE=199506L -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -march=native   -c -o misc.o misc.c
misc.c:242:3: warning: implicit declaration of function 'madvise' is invalid in C99 [-Wimplicit-function-declaration]
  madvise(data, *map, MADV_RANDOM);
  ^
misc.c:242:23: error: use of undeclared identifier 'MADV_RANDOM'
  madvise(data, *map, MADV_RANDOM);
                      ^
1 warning and 1 error generated.
make[1]: *** [misc.o] Error 1
make: *** [build] Error 2
MichaelB7 commented 5 years ago

I’m going to assume you are on Mojave OS. You might be missing some headers , run this at the command line : sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

If that file does not exist, you will need to run this first : xcode-select --install

nguyenpham commented 5 years ago

Thanks. I tried both. The first one installed well, the second one has been installed already in my machine. But the make does not work with the same error

MichaelB7 commented 5 years ago

Just for the heck of it - download the source/makefile from my fork. I anticipate you will get the same error, but after that, my next suggestion is don't use Apple clang , go grab Macports gcc or clang , gcc is faster. You will have to install MacPorts first. Apple is not really good about maintaining libraries they don't care about and if you send them a bug report, it made take year to get fixed if you're lucky. Fortunately there is MacPorts and Homebrew ( pick just one , don't try to use both) to keep everything running properly. https://github.com/MichaelB7/Cfish

Just for clarification, clang compiles the exe faster, gcc makes faster exe's - for the mac anyway.

nguyenpham commented 5 years ago

Wow, thanks, your fork works! It is compiled successfully (even there are over 20 warning).