Thread: Need help with makefile

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    Need help with makefile

    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:

    Fruit Chess Engine by Fabien Letouzey

    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....................................

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    Performance Questions

    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 know the answers to these questions because we are just learning to program.

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    A. You may be compiling in debug mode or with no optimizations. You want to pass something like "-O3" to as a compiler option. There's probably an option in you project preferences somewhere (like release build vs. debug build or something along those lines)

    B. This could again be due to compile time options, or maybe the distributed executable was built from older source. :dunno:

    C. All compilers do, it has little to do with the IDE. gcc is one of the best compilers available, you don't need to buy anything special. Just use the proper compile time flags. Have a look at the flags they use in the makefile (like "-O3").

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by New_Programmer
    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.
    As in you enabled optimisations when compiling and defined NDEBUG, but the program you built is still slower than the given binary? One possibility is that the program is written to be best optimised for a certain compiler, and gcc isn't it. It can also be the case that say, Microsoft or Intel compilers tend to generate better code because of inside knowledge of the platform, and it is a Microsoft or Intel compiler that was used to compile the binary that you were provided.

    Quote Originally Posted by New_Programmer
    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?
    You may be better off asking on the Arena forums about this. Perhaps you need to set some preprocessor definition that enables these features.

    Quote Originally Posted by New_Programmer
    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.
    The "special tools" that they come with are usually for increasing productivity rather than increasing optimisation, which is something in the domain of the compiler. One "special tool" that does allow a programmer to better optimise code is a profiler, but it tells you where the bottle necks in performance are instead of magically performing the optimisations for you. That said, gprof would be the profiler to use for gcc, but I cannot remember offhand if a gprof plugin exists for Code::Blocks.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    3
    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. And no it is not a debug compiled version. 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.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    -O3 will give you a good boost if you didn't have that before.
    -fomit-frame-pointer gives the compiler one more register "to play with" (but makes debugging harder, and it may not apply to all functions).
    -fstrict-aliasing is automatically enabled in -O3, so no need to specify that specifically.

    When you say it's the same compiler, is it the same VERSION of gcc. There are big differences between gcc 3.x and 4.x (or 2.x for that matter) - some code runs faster, some slower for each version (although in general, newer version should give better [faster] code).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 11:50 PM
  3. unix makefile won't work but works in Dev C++
    By jk1998 in forum C++ Programming
    Replies: 1
    Last Post: 06-09-2007, 03:54 PM
  4. makefile blues....
    By WaterNut in forum C Programming
    Replies: 6
    Last Post: 05-30-2005, 08:22 PM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM