使用c ++连接mysql的问题

时间:2011-04-05 04:28:26

标签: c++ mysql

每当我尝试使用mysql连接构建c ++程序时,我都会收到以下错误

g++ -o dist/Debug/GNU-Linux-x86/mysqltest build/Debug/GNU-Linux-x86/main.o
    -L/usr/local/lib/lib -L/usr/lib -lmysqlclient_r -lmysqlcppconn
    /usr/lib/libmysqlcppconn-static.a 
/usr/local/lib/lib/libmysqlcppconn.so: undefined reference to
    `vtable for std::basic_streambuf<char, std::char_traits<char> >@GLIBCPP_3.2'
/usr/local/lib/lib/libmysqlcppconn.so: undefined reference to
    `std::basic_ios<char, std::char_traits<char> >::~basic_ios()@GLIBCPP_3.2'
/usr/local/lib/lib/libmysqlcppconn.so: undefined reference to
    `std::ios_base::ios_base()@GLIBCPP_3.2'
/usr/local/lib/lib/libmysqlcppconn.so: undefined reference to
    `std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)@GLIBCPP_3.2'
make[2]: Leaving directory `/home/prasanth/NetBeansProjects/mysqltest'
/usr/local/lib/lib/libmysqlcppconn.so: undefined reference to
    `std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const@GLIBCPP_3.2'
make[1]: Leaving directory `/home/prasanth/NetBeansProjects/mysqltest'
/usr/local/lib/lib/libmysqlcppconn.so: undefined reference to
    `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@GLIBCPP_3.2'
/usr/local/lib/lib/libmysqlcppconn.so: undefined reference to
    `vtable for std::bad_alloc@GLIBCPP_3.2'

经过广泛搜索,我发现libstdc ++ 6和g ++ 4.4.5编译器之间存在一些问题

任何人都可以告诉我们如何解决这个问题

1 个答案:

答案 0 :(得分:0)

似乎GLIBCPP_3.2指的是libstdc ++ 5,而不是libstdc ++ 6.

显然,MySQL lib是使用早期版本的编译器编译的。也许你可以找到更新版本?