Hi,
xUbuntu 12.04 with gcc and g++.
"Crafty debug" returns this error :
make target=LINUX \
CC=gcc CXX=gcc \
CFLAGS='-O2 -w -g' \
CXFLAGS='-O2 -w -g' \
LDFLAGS=' -g -lpthread -lstdc++' \
opt=' -DINLINE64 -DCPUS=2' \
crafty-make
make[1]: entrant dans le répertoire « /home/vel/src/crafty-23.6 »
make[2]: entrant dans le répertoire « /home/vel/src/crafty-23.6 »
gcc -O2 -w -g -DINLINE64 -DCPUS=2 -DLINUX -c crafty.c
gcc -c -O2 -w -g -DINLINE64 -DCPUS=2 -DLINUX egtb.cpp
gcc -g -lpthread -lstdc++ -o crafty crafty.o egtb.o -lm
crafty.o: In function `Iterate':
/home/vel/src/crafty-23.6/iterate.c:181: undefined reference to `pthread_create'
collect2: ld a retourné 1 code d'état d'exécution
make[2]: *** [crafty] Erreur 1
make[2]: quittant le répertoire « /home/vel/src/crafty-23.6 »
make[1]: *** [crafty-make] Erreur 2
make[1]: quittant le répertoire « /home/vel/src/crafty-23.6 »
make: *** [debug] Erreur 2
Any idea ?
Thanks.
error compiling Crafty 23.6
Moderator: Ras
-
Sven
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: error compiling Crafty 23.6
I think the Makefile is wrong in line 338: the build rule for the "crafty" target (which is indirectly used by all main build targets) has $(LDFLAGS) too early, it should occur after the last object file at least, e.g.:
Sven
Code: Select all
crafty: $(objects) egtb.o
$(CC) -o crafty $(objects) egtb.o $(LDFLAGS) -lm $(LIBS)
-
Canoike
- Posts: 125
- Joined: Tue Jan 17, 2012 8:08 pm
Re: error compiling Crafty 23.6
Congratulations Sven. You found the mistake.
I wonder why programmers always make stupid mistakes in their makefie...
I wonder why programmers always make stupid mistakes in their makefie...
-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: error compiling Crafty 23.6
Looks like you need a -lpthreads added to the end of the link command. Most systems don't. My linux boxes for example (Fedora). But my Macbook OS/X does.Canoike wrote:Hi,
xUbuntu 12.04 with gcc and g++.
"Crafty debug" returns this error :
make target=LINUX \
CC=gcc CXX=gcc \
CFLAGS='-O2 -w -g' \
CXFLAGS='-O2 -w -g' \
LDFLAGS=' -g -lpthread -lstdc++' \
opt=' -DINLINE64 -DCPUS=2' \
crafty-make
make[1]: entrant dans le répertoire « /home/vel/src/crafty-23.6 »
make[2]: entrant dans le répertoire « /home/vel/src/crafty-23.6 »
gcc -O2 -w -g -DINLINE64 -DCPUS=2 -DLINUX -c crafty.c
gcc -c -O2 -w -g -DINLINE64 -DCPUS=2 -DLINUX egtb.cpp
gcc -g -lpthread -lstdc++ -o crafty crafty.o egtb.o -lm
crafty.o: In function `Iterate':
/home/vel/src/crafty-23.6/iterate.c:181: undefined reference to `pthread_create'
collect2: ld a retourné 1 code d'état d'exécution
make[2]: *** [crafty] Erreur 1
make[2]: quittant le répertoire « /home/vel/src/crafty-23.6 »
make[1]: *** [crafty-make] Erreur 2
make[1]: quittant le répertoire « /home/vel/src/crafty-23.6 »
make: *** [debug] Erreur 2
Any idea ?
Thanks.
OOPS. the distribution makefile does have a bug, I will fix that for sure. I don't use that Makefile most of the time... I develop on my macbook and test on a linux cluster with a custom makefile...
Last edited by bob on Mon Jun 24, 2013 6:42 am, edited 1 time in total.
-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: error compiling Crafty 23.6
I'm not sure why this would be a problem. Only issue I am aware of is that the libraries have to follow the object files. the $(LIBS) should take care of that.Sven Schüle wrote:I think the Makefile is wrong in line 338: the build rule for the "crafty" target (which is indirectly used by all main build targets) has $(LDFLAGS) too early, it should occur after the last object file at least, e.g.:SvenCode: Select all
crafty: $(objects) egtb.o $(CC) -o crafty $(objects) egtb.o $(LDFLAGS) -lm $(LIBS)
the Makefile works for me on every flavor of unix I have access to. Centos, Fedora, Mac OSX, etc... the -lpthreads is certainly required on some systems (my macbook for example) but not all (not needed on Fedora.)
the linker docs claim option order is irrelevant, even when called via gcc, except that libs must appear somewhere after the object file that references them...
Found it. the -lpthreads and such should be on the LIBS definition, not LDFLAGS. I'll get this fixed for the next version..
-
frankp
- Posts: 233
- Joined: Sun Mar 12, 2006 3:11 pm
Re: error compiling Crafty 23.6
Bob
While you are updating the Makefile you may want to check whether the changes from 23.5 to 23.6 affected the 'display' options.
'display nothing' (in console mode) does exactly that, not even displaying Crafty's move.
Frank
While you are updating the Makefile you may want to check whether the changes from 23.5 to 23.6 affected the 'display' options.
'display nothing' (in console mode) does exactly that, not even displaying Crafty's move.
Frank
-
sje
- Posts: 4675
- Joined: Mon Mar 13, 2006 7:43 pm
Re: error compiling Crafty 23.6
If -lpthreads goes in the LIBS definition, shouldn't -lm be there as well?bob wrote:Found it. the -lpthreads and such should be on the LIBS definition, not LDFLAGS. I'll get this fixed for the next version..
Symbolic uses pthreads and it doesn't need any explicit library references on Mac OS/X 10.7.5 (Lion) compile call:
Code: Select all
g++ -O3 -Wall -o ~/tmp/Symbolic *.cpp-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: error compiling Crafty 23.6
Yes. I didn't write this Makefile. It was done by someone else years ago. Really needs to be cleaned up anyway, which I might turn into a project before long...sje wrote:If -lpthreads goes in the LIBS definition, shouldn't -lm be there as well?bob wrote:Found it. the -lpthreads and such should be on the LIBS definition, not LDFLAGS. I'll get this fixed for the next version..
Symbolic uses pthreads and it doesn't need any explicit library references on Mac OS/X 10.7.5 (Lion) compile call:Code: Select all
g++ -O3 -Wall -o ~/tmp/Symbolic *.cpp
You are correct. On my Mac, -lpthread is not needed either. Might have been needed when I started with clang before moving to gcc 4.7 (clang would not compile a crafty that would run, period.)
-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: error compiling Crafty 23.6
Is this new? "display nothing" should turn off ALL output. I don't remember who asked for that or why.frankp wrote:Bob
While you are updating the Makefile you may want to check whether the changes from 23.5 to 23.6 affected the 'display' options.
'display nothing' (in console mode) does exactly that, not even displaying Crafty's move.
Frank
I suppose the question is, what should "display nothing" actually display?
-
frankp
- Posts: 233
- Joined: Sun Mar 12, 2006 3:11 pm
Re: error compiling Crafty 23.6
IRRC the help file indicatae it displays nothing but Crafty's move, which is what 23.5 does. 23.6 does not.
Hard to play blindfold chess in console mode when your opponent does not tell you its move :-)
Frank
Hard to play blindfold chess in console mode when your opponent does not tell you its move :-)
Frank