List:MySQL++« Previous MessageNext Message »
From:Mark Douglas Date:June 12 2013 1:53am
Subject:Help getting example to link - Ubuntu Raring
View as plain text  
I'm not very good with this stuff but am trying to learn. I was following
the docs and am trying to build the example from chapter 9 on an Ubuntu
Raring system. I used apt-get to install libmysql++-dev and libmysql++3
along with what I believe are the requisite mysql packages. Using the
example from the chapter and adding what I believe to be correct paths to
the Makefile I'm getting this when I try to build:

g++ -I/usr/include/mysql -I/usr/include/mysql++   -L/usr/lib -lmysqlpp
-lmysqlclient_r  hello.cpp   -o hello
/tmp/ccnjDAmG.o: In function `main':
hello.cpp:(.text+0x4b): undefined reference to
`mysqlpp::operator<<(std::ostream&, mysqlpp::String const&)'
/tmp/ccnjDAmG.o: In function
`mysqlpp::mysql_type_info::mysql_type_info(enum_field_types, bool, bool)':
hello.cpp:(.text._ZN7mysqlpp15mysql_type_infoC2E16enum_field_typesbb[_ZN7mysqlpp15mysql_type_infoC5E16enum_field_typesbb]+0x27):
undefined reference to `mysqlpp::mysql_type_info::type(enum_field_types,
bool, bool)'
/tmp/ccnjDAmG.o: In function `mysqlpp::SQLBuffer::SQLBuffer(char const*,
unsigned long, mysqlpp::mysql_type_info, bool)':
hello.cpp:(.text._ZN7mysqlpp9SQLBufferC2EPKcmNS_15mysql_type_infoEb[_ZN7mysqlpp9SQLBufferC5EPKcmNS_15mysql_type_infoEb]+0x6a):
undefined reference to `mysqlpp::SQLBuffer::replace_buffer(char const*,
unsigned long)'
collect2: error: ld returned 1 exit status
make: *** [hello] Error 1


My makefile:

CXX := g++
CXXFLAGS := -I/usr/include/mysql -I/usr/include/mysql++
LDFLAGS := -L/usr/lib -lmysqlpp -lmysqlclient_r
EXECUTABLE := hello

all: $(EXECUTABLE)

clean:
        rm -f $(EXECUTABLE) *.o


And hello.cpp itself:

#include <mysql++.h>


int main()
{
    mysqlpp::String greeting("Hello, world!");
    std::cout << greeting << std::endl;
    return 0;
}

Straight from the example page, pretty much.

I've tried adding the suggested additional LDFLAGS to no avail, and I've
also tried watching mysql compile from source on my system - unfortunately
it's using cmake and I'm not familiar with how to find the flags it's
using. Any suggestions?

Thanks,

Mark

Thread
Help getting example to link - Ubuntu RaringMark Douglas12 Jun
  • Re: Help getting example to link - Ubuntu RaringMickael Wolff12 Jun
  • Re: Help getting example to link - Ubuntu RaringWarren Young12 Jun
    • Re: Help getting example to link - Ubuntu RaringMark Douglas12 Jun
      • Re: Help getting example to link - Ubuntu RaringMickael Wolff12 Jun
      • Re: Help getting example to link - Ubuntu RaringJonathan Wakely12 Jun
        • Re: Help getting example to link - Ubuntu RaringMark Douglas12 Jun
          • Re: Help getting example to link - Ubuntu RaringJonathan Wakely12 Jun
            • Re: Help getting example to link - Ubuntu RaringJonathan Wakely12 Jun
            • Re: Help getting example to link - Ubuntu RaringMark Douglas12 Jun
              • Re: Help getting example to link - Ubuntu RaringJonathan Wakely12 Jun
              • Re: Help getting example to link - Ubuntu RaringWarren Young12 Jun