Find the answer to your Linux question:
Results 1 to 8 of 8
Hello everyone. I am new to creating make files. I have been able to create simple makefiles for those applications which do not involve database but am unable to create ...
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    8

    linux make file

    Hello everyone.

    I am new to creating make files. I have been able to create simple makefiles for those applications which do not involve database but am unable to create for the ones that do involve database. When I run that make file, it just deletes the .exe file of that application from the folder. Could anyone please help me with this.

    That's how my make file looks


    Code:
    INCLUDES = -I/usr/include/mysql++ -I/usr/include/mysql
    LIBRARY = -L/usr/lib64/ -L/usr/lib64/mysql -lmysqlpp
    SOURCE = /usr/local/babbage/bin/BreachCheck
    
    VPATH = $(INCLUDES) $(LIBRARY) $(SOURCE)
    
    OBJS = breachtester.o breachwriter.o cherrypicker.o datecl.o formatter.o frontrunner.o liffeconnect.o \
        liffe_runbreach.o logger.o positionmonitor.o reportwriter.o
    
    CC = g++
    
    DEBUG = -g
    
    CFLAGS = -Wall -c $(DEBUG)
    
    LFLAGS = -Wall $(DEBUG)
    
    liffe_runbreach-64bit : $(OBJS)
        $(CC) $(LFLAGS) $(OBJS) -o liffe_runbreach-64bit
    
    breachtester.o : breachtester.h breachtester.cpp breachwriter.h logger.h formatter.h \
            datecl.h liffeconnect.h
            $(CC) $(INCLUDES) $(CFLAGS) breachtester.cpp
    
    breachwriter.o : breachwriter.h breachwriter.cpp breachtester.h liffeconnect.h
        $(CC) $(INCLUDES) $(CFLAGS) breachwriter.cpp
    
    cherrypicker.o : cherrypicker.h cherrypicker.cpp reportwriter.h
        $(CC) $(INCLUDES) $(CFLAGS) cherrypicker.cpp
    
    datecl.o : datecl.h datecl.cpp
        $(CC) $(CFLAGS) datecl.cpp
    
    formatter.o : formatter.h formatter.cpp
        $(CC) $(CFLAGS) formatter.cpp
    
    frontrunner.o : frontrunner.h frontrunner.cpp liffeconnect.h reportwriter.h
        $(CC) $(INCLUDES) $(CFLAGS) frontrunner.cpp
    
    liffeconnect.o : liffeconnect.h liffeconnect.cpp logger.h formatter.h breachtester.h
        $(CC) $(INCLUDES) $(CFLAGS) liffeconnect.cpp
    
    logger.o : logger.h logger.cpp
        $(CC) $(CFLAGS) logger.cpp
    
    positionmonitor.o : positionmonitor.h positionmonitor.cpp logger.h formatter.h
        $(CC) $(INCLUDES) $(CFLAGS) positionmonitor.cpp
    
    reportwriter.o : reportwriter.h reportwriter.cpp frontrunner.h liffeconnect.h
        $(CC) $(INCLUDES) $(CFLAGS) reportwriter.cpp
    
    liffe_runbreach.o : liffe_runbreach.cpp datecl.h logger.h breachtester.h liffeconnect.h formatter.h \
                breachwriter.h cherrypicker.h frontrunner.h reportwriter.h
        $(CC) $(INCLUDES) $(CFLAGS) liffe_runbreach.cpp
    
    clean:
        \rm *.o *~ liffe_runbreach-64bit
    
    tar:
        tar cfv liffe_runbreach-64bit.tar breachwriter.h breachwriter.cpp cherrypicker.h \
            cherrypicker.cpp logger.cpp logger.h breachtester.cpp breachtester.h datecl.h datecl.cpp \
            frontrunner.h frontrunner.cpp positionmonitor.h positionmonitor.cpp liffe_runbreach.cpp

  2. #2
    Just Joined!
    Join Date
    Nov 2010
    Posts
    8
    it gives me the following error message

    Code:
    collect2: ld returned 1 exit status
    make: *** [liffe_runbreach-64bit] Error 1

  3. #3
    Just Joined!
    Join Date
    Dec 2007
    Posts
    3
    Could be a variety of things, but please verify that you are using just a tab (i.e. not spaces) at the beginning of the $(CC) ... line portion of your make file shown below.

    breachtester.o : breachtester.h breachtester.cpp breachwriter.h logger.h formatter.h \
    datecl.h liffeconnect.h
    $(CC) $(INCLUDES) $(CFLAGS) breachtester.cpp

    Hope this helps.

  4. #4
    Just Joined!
    Join Date
    Nov 2010
    Posts
    8
    Thanks ruslnx

    Yes I am using tabs and it still isn't working. It deletes the liffe_runbreach-64bit file which is an executable file, when I run the makefile. Any idea why?

  5. #5
    Just Joined!
    Join Date
    Dec 2007
    Posts
    3

    Question Let's try to locate the actual error...

    After you change your present working directory to where you are building/compiling via the "cd" command, enter the following command:

    rm ./*.o

    This will remove all your ".o" files.

    *******
    Then try to build each particular object file in your Makefile. For example, your Makefile contains the following lines:

    datecl.o : datecl.h datecl.cpp
    $(CC) $(CFLAGS) datecl.cpp

    If I substitute the actual commands for CC and CFLAGS into the above line, I could just enter the following command:
    g++ -Wall -c -g datecl.cpp

    The previous command should have created a "datecl.o" file. Check and see if the datecl.o file has been created using the "ls" command. If it has been created, then this is not a problem.

    Repeat for each "*.o" section in your Makefile. In other words, enter the commands manually for each "*.o" section and see if you actually create the following files:
    breachtester.o, breachwriter.o, cherrypicker.o, datecl.o, formatter.o, frontrunner.o, liffeconnect.o, logger.o, positionmonitor.o, reportwriter.o, and liffe_runbreach.o.

    If one of these doesn't build we can look at each of these sections independently. Make sure you manually include all the correct substitutions for all the variables including the $(INCLUDES) like we did for CC and CFLAGS above.

    *****************
    One other note, if your "*.cpp" files have an #include statement then you could use the target ".o" files above to build other object files to verify the build.

    For example, your Makefile has the following lines:

    liffe_runbreach.o : liffe_runbreach.cpp datecl.h logger.h breachtester.h liffeconnect.h formatter.h \
    breachwriter.h cherrypicker.h frontrunner.h reportwriter.h
    $(CC) $(INCLUDES) $(CFLAGS) liffe_runbreach.cpp

    This could actually have been built using the following command:
    iffe_runbreach.o : liffe_runbreach.cpp datecl.o logger.h breachtester.h liffeconnect.h formatter.h \
    breachwriter.h cherrypicker.h frontrunner.h reportwriter.h
    $(CC) $(INCLUDES) $(CFLAGS) liffe_runbreach.cpp

    As long as the liffe_runbreach.cpp included the following statement:
    #include "datecl.h". This way, the ""datecl.o" in the previous line would ensure that any changes to the datecl.h were automatically included.

    I normally try to build each targetted ".o" file separately and then include them with the actual build at the end like you're doing with the following section of your Makefile:
    liffe_runbreach-64bit : $(OBJS)
    $(CC) $(LFLAGS) $(OBJS) -o liffe_runbreach-64bit

    I also assume you are entering "make liffe_runbreach-64bit" command versus a "make all" which is the typical command.

    ***************
    As far as deleting the liffe_runbreach-64bit, comment out the clean section for now... Are you sure it was even created? Commenting out the clean section for now will show if it was created and it looks like you're using emacs as your editor.

    Hope this helps...
    Last edited by ruslnx; 11-23-2010 at 11:31 AM.

  6. #6
    Just Joined!
    Join Date
    Nov 2010
    Posts
    8
    Thanks a LOT ruslnx

    Let me follow all your suggestions/instructions and will get back.

    Many thanks once again

  7. #7
    Just Joined!
    Join Date
    Nov 2010
    Posts
    8
    enter the commands manually for each "*.o" section and see if you actually create the following files:
    breachtester.o, breachwriter.o, cherrypicker.o, datecl.o, formatter.o, frontrunner.o, liffeconnect.o, logger.o, positionmonitor.o, reportwriter.o, and liffe_runbreach.o.

    It did not create .o files for all those .cpp files which involve dealing with database which are:
    breachtester.cpp, breachwriter.cpp, cherrypicker.cpp, frontrunner.cpp, liffeconnect.cpp, positionmonitor.cpp, reportwriter.cpp, and liffe_runbreach.cpp.

    and it did creat .o files this way for
    datecl.cpp formatter.cpp logger.cpp

    and when I ran the make file (not manually for each), no .o file was created for any .cpp file

    Commenting out the clean section for now will show if it was created
    commenting out the clean section did create liffe_runbreach-64bit and surprisingly running make file again is no more deleting the liffe_runbreach-64bit. I dont know why.

    all the errors I see now are related to database connectivity. Should I post them.

    Thanks

  8. #8
    Just Joined!
    Join Date
    Dec 2007
    Posts
    3

    Sorry I've been away for a few days...

    Looks like you've determined that you haven't included some other libraries for the database. I know mysql requires some libraries for the database linking but I don't remember which ones off the top of my head. Refer to MySql links for this info.,,

    Sorry I have been unable to help during the paat few days...

    I hope I helped.

    Happy Thanksgiving!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...