bctboi23 / CeeChess

UCI / Xboard compliant chess engine written in C
6 stars 1 forks source link

Can't compile on linux; undefined reference to `log' #1

Closed emdio closed 4 years ago

emdio commented 4 years ago

System ubuntu, gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2).

After cloning the repo, I cd to src, run make command and get this error message:

$ make gcc xboard.c seeChess.c uci.c evaluate.c eval.h pvtable.c init.c bitboards.c hashkeys.c board.c data.c attack.c io.c movegen.c validate.c makemove.c perft.c search.c misc.c -o seeChess-v1.2.exe -O3 -s /usr/bin/ld: /tmp/ccFVmu60.o: in function AlphaBeta': search.c:(.text+0xa18): undefined reference tolog' /usr/bin/ld: search.c:(.text+0xa2d): undefined reference to `log' collect2: error: ld returned 1 exit status make: *** [makefile:2: all] Error 1

bctboi23 commented 4 years ago

I think I figured out the issue. In my program, log is used from a C standard library (namely, math.h). While using MinGW (which is what I used for the compile), the C standard libraries are included by default. On linux, however, the C libraries need to be added into the compile using the -lm flag at the end of the compile command. So, if you add -lm to the end of the makefile, it should work in linux. I will add a separate makefile for linux on the next update.

emdio commented 4 years ago

You're right; adding "-lm" to the compiling command worked perfectly.