Visual Studio Linker не загружает библиотеку - PullRequest
0 голосов
/ 05 ноября 2018

Я только что установил MySQL Connector / C ++, загрузив его здесь и переместив содержимое include в /usr/include и содержимое lib64 в /usr/lib. Я также добавил параметр компоновщика -lmysqlcppconn8 в параметры компоновщика командной строки Visual Studio.

Код:

/* Other includes... */
#include<mysqlx/xdevapi.h>

int main(const int argc, const char* argv[]) {
    mysqlx::Session sess("localhost", 33060, "root", "MY_PW");
    return EXIT_SUCCESS;
}

Когда я теперь включаю mysqlx/xdevapi.h в свой проект и инициализирую Сеанс , как описано здесь Я получаю следующие ошибки:

1>Validating architecture
1>Starting remote build
1>Compiling sources:
1>Linking objects
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::common::Value::Value(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
1>/usr/include/mysqlx/common/value.h(119): error : undefined reference to `vtable for mysqlx::common::Value'
1>/usr/include/mysqlx/common/value.h(119): error : undefined reference to `vtable for mysqlx::common::Value'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::common::Value::Value(unsigned long)':
1>/usr/include/mysqlx/common/value.h(129): error : undefined reference to `vtable for mysqlx::common::Value'
1>/usr/include/mysqlx/common/value.h(129): error : undefined reference to `vtable for mysqlx::common::Value'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::common::Value::~Value()':
1>/usr/include/mysqlx/common/value.h(56): error : undefined reference to `vtable for mysqlx::common::Value'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : /usr/include/mysqlx/common/value.h:56: more undefined references to `vtable for mysqlx::common::Value' follow
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::string::string(char const*)':
1>/usr/include/mysqlx/devapi/common.h(100): error : undefined reference to `mysqlx::string::Impl::from_utf8(mysqlx::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::string::string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
1>/usr/include/mysqlx/devapi/common.h(105): error : undefined reference to `mysqlx::string::Impl::from_utf8(mysqlx::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::string::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >[abi:cxx11]() const':
1>/usr/include/mysqlx/devapi/common.h(115): error : undefined reference to `mysqlx::string::Impl::to_utf8[abi:cxx11](mysqlx::string const&)'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::DbDoc::DbDoc()':
1>/usr/include/mysqlx/devapi/document.h(153): error : undefined reference to `vtable for mysqlx::DbDoc'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::DbDoc::~DbDoc()':
1>/usr/include/mysqlx/devapi/document.h(127): error : undefined reference to `vtable for mysqlx::DbDoc'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::Value::print(std::ostream&) const':
1>/usr/include/mysqlx/devapi/document.h(507): error : undefined reference to `mysqlx::common::Value::print(std::ostream&) const'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::common::Value::Value(mysqlx::common::Value&&)':
1>/usr/include/mysqlx/common/value.h(56): error : undefined reference to `vtable for mysqlx::common::Value'
1>/usr/include/mysqlx/common/value.h(56): error : undefined reference to `vtable for mysqlx::common::Value'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::common::Value::Value(mysqlx::common::Value const&)':
1>/usr/include/mysqlx/common/value.h(56): error : undefined reference to `vtable for mysqlx::common::Value'
1>/usr/include/mysqlx/common/value.h(56): error : undefined reference to `vtable for mysqlx::common::Value'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::internal::Session_detail::~Session_detail()':
1>/usr/include/mysqlx/devapi/detail/session.h(369): error : undefined reference to `mysqlx::internal::Session_detail::close()'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `mysqlx::Session::Session(mysqlx::SessionSettings)':
1>/usr/include/mysqlx/xdevapi.h(1101): error : undefined reference to `mysqlx::internal::Session_detail::Session_detail(mysqlx::common::Settings_impl&)'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `void mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::set<true, mysqlx::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mysqlx::SessionOption, unsigned int&, mysqlx::SessionOption, mysqlx::string const&>(mysqlx::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mysqlx::SessionOption&&, unsigned int&, mysqlx::SessionOption&&, mysqlx::string const&)':
1>/usr/include/mysqlx/devapi/detail/settings.h(67): error : undefined reference to `mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::common::Value>, std::allocator<std::pair<int, mysqlx::common::Value> > >&&)'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `void mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::set<true, mysqlx::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(mysqlx::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)':
1>/usr/include/mysqlx/devapi/detail/settings.h(67): error : undefined reference to `mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::common::Value>, std::allocator<std::pair<int, mysqlx::common::Value> > >&&)'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : In function `void mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::set<true, mysqlx::SessionOption, mysqlx::string const&>(mysqlx::SessionOption, mysqlx::string const&)':
1>/usr/include/mysqlx/devapi/detail/settings.h(67): error : undefined reference to `mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::common::Value>, std::allocator<std::pair<int, mysqlx::common::Value> > >&&)'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : (.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x18): undefined reference to `typeinfo for mysqlx::common::Value'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : (.rodata._ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTVN6mysqlx5ValueE]+0x20): undefined reference to `mysqlx::common::Value::print(std::ostream&) const'
1>C:\Users\Paul\source\repos\LSTGA\LSTGA\obj\x64\Debug\Main.o : error : (.rodata._ZTIN6mysqlx5ValueE[_ZTIN6mysqlx5ValueE]+0x28): undefined reference to `typeinfo for mysqlx::common::Value'
1>collect2 : error : ld returned 1 exit status
1>Done building project "LSTGA.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Дополнительная информация:

  • Удаленная ОС: Ubuntu 16.04 LTS x64
  • MySQL Server: 8.0.13 (XPlugin включен)
  • gcc / g ++: 5.4.0 (аналогично BUILDINFO.txt MySQL Connector)

Заранее спасибо. - Миндинг

1 Ответ

0 голосов
/ 09 ноября 2018

Я получил его на работу сейчас, поставив mysqlcppconn8 в Library Dependencies вместо -lmysqlcppconn8 в Дополнительные параметры (оба в Project> Properties> Linker ). Visual studio генерирует -l"mysqlcppconn8" и работает отлично.

Я не знаю точно, почему предыдущий не сработал, но, возможно, это из-за числа в имени библиотеки, требующего кавычки . В любом случае, использование опции Library Dependencies является гораздо более чистым решением.

Надеюсь, это поможет. -Minding

...