• 0

c++ Need help compiling a makefile


Question

Hello! I'm just starting to learn c++. I also like to play chess against other people and against computer programs. There is a very famous chess program called Fruit 2.1 that I have been trying to compile the windows version before I edit the source code to change its playing style. You can find the source at:

http://arctrix.com/nas/chess/fruit/

I'm using code::blocks IDE and have tried the watcom, borland 5.5, and the gnu gcc compilers to compile the makefile. gnu gcc gives me the least amount of errors, only one error to be exact.

***************

the makefile build log says:

pv.cpp random.cpp recog.cpp search.cpp search_full.cpp see.cpp sort.cpp square.cpp trans.cpp util.cpp value.cpp vector.cpp > .depend

mingw32-make.exe: *** No rule to make target `Release'. Stop.

Process terminated with status 2 (0 minutes, 2 seconds)

1 errors, 0 warnings

***************

the makefile build messages says:

Makefile|47|.depend: No such file or directory|

||=== Build finished: 1 errors, 0 warnings ===|

***************

the makefile looks like this:

==========================================

# files

EXE = fruit

OBJS = attack.o board.o book.o eval.o fen.o hash.o list.o main.o material.o \

move.o move_check.o move_do.o move_evasion.o move_gen.o move_legal.o \

option.o pawn.o piece.o posix.o protocol.o pst.o pv.o random.o recog.o \

search.o search_full.o see.o sort.o square.o trans.o util.o value.o \

vector.o

# rules

all: $(EXE) .depend

clean:

$(RM) *.o .depend gmon.out

# general

CXX = g++

CXXFLAGS = -pipe

LDFLAGS = -lm

# C++

CXXFLAGS += -fno-exceptions -fno-rtti

# optimisation

CXXFLAGS += -O3 -fstrict-aliasing

CXXFLAGS += -fomit-frame-pointer

# CXXFLAGS += -march=athlon-xp # SELECT ME

# strip

LDFLAGS += -s

# dependencies

$(EXE): $(OBJS)

$(CXX) $(LDFLAGS) -o $@ $(OBJS)

.depend:

$(CXX) -MM $(OBJS:.o=.cpp) > $@

include .depend

==========================================

could somebody explain to me in the greatest of layman's terms what i have to do to fix this....................................

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

I've compiled the code using Code::Blocks and Dev C++ without using the makefile although I did get some compiler warnings. When I used the makefile with Dev++ I got an '.depend' error stating it could not find the file. Haven't got time right now to try it in Code::Blocks.

You could just compile without the makefile and start to make some modifications.

Link to comment
Share on other sites

  • 0

Just tried it using Code::Blocks under Windows and it compiled fine, with a few warnings.

What I did :

download and unzip fruit in a folder

create a new empty project in Code::Blocks

right-click project, select Add Files Recursively

select the src folder of the fruit directory

click ok

build (CTRL+F9)

The compiler is Code::Blocks's default, g++ I guess.

Link to comment
Share on other sites

  • 0

Alright, now i'm getting somewhere. I finally compiled the program without the makefile on code::blocks. The program runs fine, but I have some new questions that I hope others can answer.

A: Why is my compile so slow? I checked all the optimizations I could find in the GNU GCC compiler settings. The downloaded source comes with an executable that runs much faster. Same program but different speeds.

B: The downloaded executable displays information on the "Arena GUI" (i.e. knodes/second, total nodes evaluated) that my executable does not. Why?

C: Are all the free compilers that much slower than the commercial compilers? If so, that is a major bummer. I'll have to buy me an expensive compiler then.

Link to comment
Share on other sites

  • 0

A. If you are compiling with debug symbols, it's normal that the product is slower. Try compiling a release build. If you already tried that, I've no idea.

B. You'd have to check the source code, maybe he has enabled some stuff in his build that you haven't, it might depend on some symbols. Maybe it's just an external config file read at run time too.

C. I don't know of any non-free C++ compilers... MSVC++ is not open-source, but it's free too. And g++ is just as good (if not better).

Link to comment
Share on other sites

  • 0

Sorry, I guess I worded somethings incorrectly and am being misunderstood. Therefore I will repost my questions again. I finally compiled the Fruit 2.1 chess engine source without the makefile using the code::blocks IDE and the GNU GCC compiler. The executable runs fine, but I have some new questions that I hope others can answer.

A: The downloaded Fruit 2.1 chess engine source comes with an executable that runs much faster than the one I created with the GNU GCC compiler. Why is the executable I created so much slower? I have not modified the source files yet and I tried checking some of the speed optimizations in the GNU GCC compiler settings. The two programs do exactly the same thing, but the one I created is much slower.

B: The downloaded Fruit 2.1 chess engine executable displays information on the "Arena GUI" (i.e. knodes/second, total nodes evaluated) that my executable does not. Why?

C: Do all commercial IDEs come with some special tools to get the most out of certain compilers? In other words are they able to fully optimize source code to create a better performing executable while those of us who use a free IDE like code::blocks cannot. If so, that is a major bummer because then I'll have to buy me an expensive IDE that can better optimize code and better utilize certain c++ compilers.

Please remember that some of us don't the answers to these questions because we are just learning to program.

Link to comment
Share on other sites

  • 0

I believe Dr_Asik has already answered your questions. How much slower is your executable running?

A: Check you're not compiling with the debugging symbols flag. In Code::Blocks go to Settings --> Compiler & Debugger and make sure the '-g' compiler flag is unchecked. Right now the only compiler flags I'm using is -O (optimise for speed) and -Wall which enabled all the standard compiler warnings.

B: As Dr_Asik said.

C: G++ does a pretty good job. you can even see that if he used the makefile to compile his copy, he used g++ also.

CXX = g++

You also mention that you're just starting out to learn C++. If so is the execution speed of the program really that important? And is the best way to learn to try and alter the source code for a complete chess engine?

You might be better starting with the tutorials here.

edit:

Forgot to mention before in his makefile he also has these compiler flags:

CXXFLAGS += -fno-exceptions -fno-rtti

# optimisation

CXXFLAGS += -O3 -fstrict-aliasing
CXXFLAGS += -fomit-frame-pointer

You can add them by going to the Other Options tab in the compiler settings.

Edited by ViZioN
Link to comment
Share on other sites

  • 0

Thanks to everyone who has answered questions and tried to help. It is much appreciated.

Yes, most of my questions had already been answered except for making the makefile work in code::blocks. I really meant to reword and post the part "c" question because i'm trying to figure out why my executable is a little slower. For example, in a 50 second opening position analysis my executable will evaluate approximately 23,300,000 nodes and the original executable will do approximately 32,200,000 nodes. In chess, all things being equal, if you can search and evaluate more positions than your opponent you will win. The speed difference is very puzzling to me because i'm using the same compiler "g++" and have checked the same optimizations for the compiler. Although I have not tried setting:

=============================

# C++

CXXFLAGS += -fno-exceptions -fno-rtti

# optimisation

CXXFLAGS += -O3 -fstrict-aliasing

CXXFLAGS += -fomit-frame-pointer

=============================

in the "Other Options" submenu. Would a simple copy and paste work? Finally, I am not really going modify the source code for Fruit 2.1 just yet because I don't know enough to do it, but am only changing the evaluation parameters to change its evaluation and playing style. I am currently working through several online tutorials to get better at c++. Any recommendations for online tutorials?

Oh and if anybody else has had the same problem using a makefile on code::blocks just go to the code::blocks forum and look for the "problems with makefile" thread. I finally got the makefile to work as well.

I will try the above optimizations by copy paste and see if that works and makes a difference but I don't think it will because the executable compiled with the makefile should have taken that into account already and it too is quite a bit slower. I would just like to know why it is slower. Perhaps the source code that is distributed is a little different. Or does the machine itself make any difference and if so why should it make a difference after all the executables were all created with g++ and the same optimizations. I think i'm not the only person who would like to know.

Link to comment
Share on other sites

  • 0

I tried it, out of curiosity, with Arena. The precompiled exe computes about 1.2M nodes/s, while the gcc version with all optimisations I could turn on computes about 0.7M. I tried compiling with MSVC with maximum optimizations, and I get 0.9M, which leads me to think that either I got the incorrect options with gcc, or MSVC is better at optimising. MSVC likes to ouput a crapload of warnings too, I got over 1000. :p

In any case, I don't know how they made their exe so fast, maybe you could try contacting them. I'm really not versed in this subject. If you're just starting out in programming, squeezing ultimate performance isn't something you should invest too much time in anyway.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.