Использование MySQL коннектора-C ++ для подключения MySQL сервера, немного демо, но застрял - PullRequest
0 голосов
/ 22 декабря 2018

Мой сервер - Ubuntu, код:

#include <mysqlx/xdevapi.h>
#include <iostream>

using namespace mysqlx;
int main()
{
    const char *url = "mysqlx://root@127.0.0.1";
    std::cout << "Create session on " << url <<std::endl;
    Session sess(url);
    Schema sch = sess.getSchema("IM.User");
}

, когда я его скомпилировал, получил это:

 g++ dbtest.cpp -g -std=c++11 -L/usr/lib64/ -lmysqlcppconn8-static -I/usr/include/mysqlx -lssl -lpthread -lcrypto -o dbtest.o
----------------------------------------------------------------------
/tmp/cccFQIzq.o: In function `mysqlx::string::string(char const*)':
/usr/include/mysqlx/devapi/common.h:100: undefined reference to `mysqlx::string::Impl::from_utf8(mysqlx::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/cccFQIzq.o: In function `mysqlx::string::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >() const':
/usr/include/mysqlx/devapi/common.h:115: undefined reference to `mysqlx::string::Impl::to_utf8[abi:cxx11](mysqlx::string const&)'
/tmp/cccFQIzq.o: In function `mysqlx::SessionSettings::SessionSettings(mysqlx::string const&)':
/usr/include/mysqlx/devapi/settings.h:339: undefined reference to `mysqlx::common::Settings_impl::set_from_uri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status

Я что-то потерял?

...