Find the answer to your Linux question:
Results 1 to 2 of 2
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    8

    Linux makefile


    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. It isnt creating the exe file liffe_runbreach-64bit at all.

    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
    There is no error in the code because when I compile the code through the following command, it gives me no error

    Code:
    g++ -I/usr/include/mysql++ -I/usr/include/mysql -L/usr/lib64 -L/usr/lib64/mysql -lmysqlpp formatter.cpp logger.cpp datecl.cpp breachtester.cpp liffeconnect.cpp breachwriter.cpp cherrypicker.cpp frontrunner.cpp positionmonitor.cpp reportwriter.cpp liffe_runbreach.cpp -o liffe_runbreach-64bit
    the error msg is:

    Code:
    g++ -Wall -g breachtester.o breachwriter.o cherrypicker.o datecl.o formatter.o frontrunner.o liffeconnect.o liffe_runbreach.o logger.o positionmonitor.o reportwriter.o -o liffe_runbreach-64bit
    breachtester.o: In function `BreachTester::ProcessQuery(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
    /usr/local/babbage/bin/BreachCheck/breachtester.cpp:85: undefined reference to `mysqlpp::Connection::query(char const*)'
    breachtester.o: In function `BreachTester::GetHalfTrades(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
    /usr/local/babbage/bin/BreachCheck/breachtester.cpp:265: undefined reference to `mysqlpp::Connection::query(char const*)'
    breachtester.o: In function `BreachTester::DeleteDupes(std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >&)':
    /usr/local/babbage/bin/BreachCheck/breachtester.cpp:315: undefined reference to `mysqlpp::Connection::query(char const*)'
    breachtester.o: In function `DeBreachTester::ProcessQuery(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
    /usr/local/babbage/bin/BreachCheck/breachtester.cpp:360: undefined reference to `mysqlpp::Connection::query(char const*)'
    breachtester.o: In function `DeBreachTester::GetHalfTradeQueryString(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
    /usr/local/babbage/bin/BreachCheck/breachtester.cpp:461: undefined reference to `mysqlpp::Connection::query(char const*)'
    breachtester.o:/usr/local/babbage/bin/BreachCheck/breachtester.cpp:550: more undefined references to `mysqlpp::Connection::query(char const*)' follow
    breachtester.o: In function `BlockMABreachTester::ProcessBlockMA(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >*> > >&, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&, unsigned long&, unsigned long&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned long&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
    /usr/local/babbage/bin/BreachCheck/breachtester.cpp:1792: undefined reference to `mysqlpp::Query::reset()'
    /usr/local/babbage/bin/BreachCheck/breachtester.cpp:1837: undefined reference to `mysqlpp::Query::reset()'
    breachtester.o: In function `mysqlpp::String::c_str() const':
    /usr/include/mysql++/mystring.h:288: undefined reference to `mysqlpp::String::data() const'
    breachtester.o: In function `mysqlpp::String::operator char const*() const':
    /usr/include/mysql++/mystring.h:533: undefined reference to `mysqlpp::String::data() const'
    breachtester.o: In function `mysqlpp::Row::operator[](int) const':
    /usr/include/mysql++/row.h:328: undefined reference to `mysqlpp::Row::at(unsigned long) const'
    breachtester.o: In function `mysqlpp::Query::str()':
    /usr/include/mysql++/query.h:277: undefined reference to `mysqlpp::Query::str(mysqlpp::SQLQueryParms&)'
    breachtester.o: In function `mysqlpp::Query::store()':
    /usr/include/mysql++/query.h:467: undefined reference to `mysqlpp::Query::str(mysqlpp::SQLQueryParms&)'
    /usr/include/mysql++/query.h:467: undefined reference to `mysqlpp::SQLTypeAdapter::SQLTypeAdapter(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
    /usr/include/mysql++/query.h:467: undefined reference to `mysqlpp::Query::store(mysqlpp::SQLTypeAdapter const&)'
    breachtester.o: In function `unsigned long mysqlpp::String::do_conv<unsigned long>(char const*) const':
    /usr/include/mysql++/mystring.h:615: undefined reference to `mysqlpp::String::length() const'
    /usr/include/mysql++/mystring.h:615: undefined reference to `mysqlpp::String::data() const'
    /usr/include/mysql++/mystring.h:645: undefined reference to `mysqlpp::String::data() const'
    /usr/include/mysql++/mystring.h:645: undefined reference to `mysqlpp::String::length() const'
    cherrypicker.o: In function `CherryPicker::FindCherryPicking()':
    /usr/local/babbage/bin/BreachCheck/cherrypicker.cpp:42: undefined reference to `mysqlpp::Connection::query(char const*)'
    cherrypicker.o: In function `CherryPicker::GetCherryHT(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
    /usr/local/babbage/bin/BreachCheck/cherrypicker.cpp:141: undefined reference to `mysqlpp::Connection::query(char const*)'
    cherrypicker.o: In function `long mysqlpp::String::do_conv<long>(char const*) const':
    /usr/include/mysql++/mystring.h:615: undefined reference to `mysqlpp::String::length() const'
    /usr/include/mysql++/mystring.h:615: undefined reference to `mysqlpp::String::data() const'
    /usr/include/mysql++/mystring.h:645: undefined reference to `mysqlpp::String::data() const'
    /usr/include/mysql++/mystring.h:645: undefined reference to `mysqlpp::String::length() const'
    frontrunner.o: In function `FrontRunner::FindTrsFR()':
    /usr/local/babbage/bin/BreachCheck/frontrunner.cpp:69: undefined reference to `mysqlpp::Connection::query(char const*)'
    frontrunner.o: In function `FrontRunner::GetHalfTrades(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
    /usr/local/babbage/bin/BreachCheck/frontrunner.cpp:550: undefined reference to `mysqlpp::Connection::query(char const*)'
    liffe_runbreach.o: In function `main':
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:107: undefined reference to `mysqlpp::Connection::Connection(bool)'
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:111: undefined reference to `mysqlpp::Connection::connect(char const*, char const*, char const*, char const*, unsigned int)'
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:214: undefined reference to `mysqlpp::Connection::~Connection()'
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:214: undefined reference to `mysqlpp::Connection::~Connection()'
    liffe_runbreach.o: In function `PreProcessDB(mysqlpp::Connection&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int&, int&, unsigned long&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:235: undefined reference to `mysqlpp::Connection::query(char const*)'
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:240: undefined reference to `mysqlpp::Query::operator void*() const'
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:288: undefined reference to `mysqlpp::Query::reset()'
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:325: undefined reference to `mysqlpp::Query::reset()'
    liffe_runbreach.o: In function `ProcessDB(mysqlpp::Connection&)':
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:448: undefined reference to `mysqlpp::Connection::query(char const*)'
    liffe_runbreach.o: In function `PostProcessDB(mysqlpp::Connection&)':
    /usr/local/babbage/bin/BreachCheck/liffe_runbreach.cpp:464: undefined reference to `mysqlpp::Connection::query(char const*)'
    liffe_runbreach.o: In function `mysqlpp::Query::execute()':
    /usr/include/mysql++/query.h:342: undefined reference to `mysqlpp::Query::str(mysqlpp::SQLQueryParms&)'
    /usr/include/mysql++/query.h:342: undefined reference to `mysqlpp::SQLTypeAdapter::SQLTypeAdapter(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
    /usr/include/mysql++/query.h:342: undefined reference to `mysqlpp::Query::execute(mysqlpp::SQLTypeAdapter const&)'
    positionmonitor.o: In function `PositionMonitor::GetPositionInfo(std::vector<PositionMonitor::PosMonitor, std::allocator<PositionMonitor::PosMonitor> >&)':
    /usr/local/babbage/bin/BreachCheck/positionmonitor.cpp:43: undefined reference to `mysqlpp::Connection::query(char const*)'
    positionmonitor.o: In function `bool mysqlpp::String::operator==<char [2]>(char const (&) [2]) const':
    /usr/include/mysql++/mystring.h:495: undefined reference to `mysqlpp::String::compare(char const*) const'
    collect2: ld returned 1 exit status
    make: *** [liffe_runbreach-64bit] Error 1
    Where am I going wrong? Am I not providing the correct mysql path? Could anyone please help me with this.

  2. #2
    Just Joined!
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    41
    I think you should add $(LIBRARY) where it is needed, like this:
    $(CC) $(INCLUDES) $(LIBRARY) $(CFLAGS) breachtester.cpp

    Also, you don't have an "all" target. I don't know if it is necessary, but you could add
    all : liffe_runbreach-64bit

Posting Permissions

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