MySQL Forums
Forum List  »  Connector/C++

cmake error when using xdevapi
Posted by: i wont tell u i wont tell u
Date: November 20, 2022 04:39AM

hello there

i finally managed to include this lib in my project by installing

mysql-apt-config_0.8.24-1_all.deb
mysql-community-client-plugins
libmysqlcppconn8-2_8.0.31-1ubuntu22.04_amd64.deb
libmysqlcppconn9_8.0.31-1ubuntu22.04_amd64.deb
libmysqlcppconn-dev_8.0.31-1ubuntu22.04_amd64.deb

i dont know why it has to be so complicated

now when i work in IDE everything seems fine i can navigate myself to declarations in /usr/include/mysql-cppconn-8/mysqlx/xdevapi.h but when im trying to build and compile im getting error

this is very simplified representation of my cmake config

add_library(MySQL MySQL.h MySQL.cpp)
target_link_libraries(MySQL PUBLIC Config mysqlcppconn)
add_executable(Auth Auth/Main.cpp)

inside MySQL.cpp i have

#include <mysql-cppconn-8/mysqlx/xdevapi.h>

just including it already causes this

FAILED: Servers/Auth
: && /usr/bin/c++ -g Servers/CMakeFiles/Auth.dir/Auth/Main.cpp.o -o Servers/Auth Core/Models/Auth/libAccount.a Core/Models/libModel.a Database/MySQL/libMySQL.a Config/libConfig.a Support/libDotEnv.a -lmysqlcppconn && :
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): warning: relocation against `_ZTVN6mysqlx4abi22r05DbDocE' in read-only section `.text._ZN6mysqlx4abi22r05DbDocD2Ev[_ZN6mysqlx4abi22r05DbDocD5Ev]'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::string::traits<char>::to_str[abi:cxx11](mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:225: undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::DbDoc()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:107: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::~DbDoc()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:81: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Value::print(std::ostream&) const':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:508: undefined reference to `mysqlx::abi2::r0::common::Value::print(std::ostream&) const'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTCN6mysqlx4abi22r05ValueE0_NS1_6common5ValueE[_ZTVN6mysqlx4abi22r05ValueE]+0x18): undefined reference to `typeinfo for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTCN6mysqlx4abi22r05ValueE0_NS1_6common5ValueE[_ZTVN6mysqlx4abi22r05ValueE]+0x20): undefined reference to `mysqlx::abi2::r0::common::Value::print(std::ostream&) const'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTIN6mysqlx4abi22r05ValueE[_ZTIN6mysqlx4abi22r05ValueE]+0x28): undefined reference to `typeinfo for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

and when i add actual code to execute simple select it gives this

FAILED: Servers/Auth
: && /usr/bin/c++ -g Servers/CMakeFiles/Auth.dir/Auth/Main.cpp.o -o Servers/Auth Core/Models/Auth/libAccount.a Core/Models/libModel.a Database/MySQL/libMySQL.a Config/libConfig.a Support/libDotEnv.a -lmysqlcppconn && :
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): warning: relocation against `_ZTVN6mysqlx4abi22r06common5ValueE' in read-only section `.text._ZN6mysqlx4abi22r06common5ValueD1Ev[_ZN6mysqlx4abi22r06common5ValueD1Ev]'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::common::Settings_impl::Data::Data()':
/usr/include/mysql-cppconn-8/mysqlx/common/settings.h:217: undefined reference to `mysqlx::abi2::r0::common::Settings_impl::Data::init_connection_attr()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::common::Value::~Value()':
/usr/include/mysql-cppconn-8/mysqlx/common/value.h:61: undefined reference to `vtable for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: /usr/include/mysql-cppconn-8/mysqlx/common/value.h:61: undefined reference to `vtable for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::string::traits<char>::from_str(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:220: undefined reference to `mysqlx::abi2::r0::string::Impl::from_utf8(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::string::traits<char>::to_str[abi:cxx11](mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:225: undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::DbDoc()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:107: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::~DbDoc()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:81: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Value::print(std::ostream&) const':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:508: undefined reference to `mysqlx::abi2::r0::common::Value::print(std::ostream&) const'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::DbDoc(mysqlx::abi2::r0::DbDoc const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:81: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Row::get(unsigned long)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/row.h:162: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::get_val(unsigned long)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Row::set(unsigned long, mysqlx::abi2::r0::Value const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/row.h:180: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::get_val(unsigned long)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Row::operator[](unsigned long)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/row.h:208: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::ensure_impl()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns>::~Row_result_detail()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/result.h:314: undefined reference to `mysqlx::abi2::r0::internal::Result_detail::~Result_detail()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::TableSelect::TableSelect(mysqlx::abi2::r0::Table&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/table_crud.h:266: undefined reference to `mysqlx::abi2::r0::internal::Crud_factory::mk_select(mysqlx::abi2::r0::Table&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Schema_detail::Name_src::~Name_src()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/session.h:178: undefined reference to `mysqlx::abi2::r0::internal::Query_src::~Query_src()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Schema_detail::Table_src::Table_src(mysqlx::abi2::r0::Schema const&, mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/session.h:205: undefined reference to `mysqlx::abi2::r0::internal::Schema_detail::Name_src::Name_src(mysqlx::abi2::r0::Schema const&, mysqlx::abi2::r0::internal::Schema_detail::Obj_type, mysqlx::abi2::r0::string const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Session_detail::~Session_detail()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/session.h:379: undefined reference to `mysqlx::abi2::r0::internal::Session_detail::close()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Session::Session(mysqlx::abi2::r0::SessionSettings)':
/usr/include/mysql-cppconn-8/mysqlx/xdevapi.h:1684: undefined reference to `mysqlx::abi2::r0::internal::Session_detail::Session_detail(mysqlx::abi2::r0::common::Settings_impl&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Row_detail::set_values<mysqlx::abi2::r0::Value>(unsigned long, mysqlx::abi2::r0::Value)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/row.h:96: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::ensure_impl()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns>::get_row()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/result.h:372: undefined reference to `mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns>::iterator_next()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Result_common<mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns> >::Result_common(mysqlx::abi2::r0::common::Result_init&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/result.h:149: undefined reference to `mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns>::Row_result_detail(mysqlx::abi2::r0::common::Result_init&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Iterator<mysqlx::abi2::r0::internal::Schema_detail::Table_src, mysqlx::abi2::r0::Table, long, mysqlx::abi2::r0::Table*, mysqlx::abi2::r0::Table&>::operator*() const':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:441: undefined reference to `mysqlx::abi2::r0::internal::Schema_detail::Table_src::iterator_get()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::set<true, mysqlx::abi2::r0::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mysqlx::abi2::r0::SessionOption::Enum, unsigned int&, mysqlx::abi2::r0::SessionOption::Enum, mysqlx::abi2::r0::string const&>(mysqlx::abi2::r0::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mysqlx::abi2::r0::SessionOption::Enum&&, unsigned int&, mysqlx::abi2::r0::SessionOption::Enum&&, mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/settings.h:68: undefined reference to `mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::abi2::r0::Value>, std::allocator<std::pair<int, mysqlx::abi2::r0::Value> > >&&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::set<true, mysqlx::abi2::r0::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(mysqlx::abi2::r0::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/settings.h:68: undefined reference to `mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::abi2::r0::Value>, std::allocator<std::pair<int, mysqlx::abi2::r0::Value> > >&&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::set<true, mysqlx::abi2::r0::SessionOption, mysqlx::abi2::r0::string const&>(mysqlx::abi2::r0::SessionOption, mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/settings.h:68: undefined reference to `mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::abi2::r0::Value>, std::allocator<std::pair<int, mysqlx::abi2::r0::Value> > >&&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Args_processor<mysqlx::abi2::r0::internal::Row_detail, std::pair<mysqlx::abi2::r0::internal::Row_detail::Impl*, unsigned long>*>::process_args1<mysqlx::abi2::r0::Value, , (void*)0>(std::pair<mysqlx::abi2::r0::internal::Row_detail::Impl*, unsigned long>*, mysqlx::abi2::r0::Value)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:862: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::process_one(std::pair<mysqlx::abi2::r0::internal::Row_detail::Impl*, unsigned long>*, mysqlx::abi2::r0::Value const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Iterator<mysqlx::abi2::r0::internal::Schema_detail::Table_src, mysqlx::abi2::r0::Table, long, mysqlx::abi2::r0::Table*, mysqlx::abi2::r0::Table&>::Iterator(mysqlx::abi2::r0::internal::Schema_detail::Table_src&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:404: undefined reference to `mysqlx::abi2::r0::internal::Query_src::iterator_next()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTCN6mysqlx4abi22r05ValueE0_NS1_6common5ValueE[_ZTVN6mysqlx4abi22r05ValueE]+0x18): undefined reference to `typeinfo for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTCN6mysqlx4abi22r05ValueE0_NS1_6common5ValueE[_ZTVN6mysqlx4abi22r05ValueE]+0x20): undefined reference to `mysqlx::abi2::r0::common::Value::print(std::ostream&) const'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTIN6mysqlx4abi22r08internal13Schema_detail8Name_srcE[_ZTIN6mysqlx4abi22r08internal13Schema_detail8Name_srcE]+0x10): undefined reference to `typeinfo for mysqlx::abi2::r0::internal::Query_src'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTIN6mysqlx4abi22r08internal17Row_result_detailINS1_7ColumnsEEE[_ZTIN6mysqlx4abi22r08internal17Row_result_detailINS1_7ColumnsEEE]+0x10): undefined reference to `typeinfo for mysqlx::abi2::r0::internal::Result_detail'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTIN6mysqlx4abi22r05ValueE[_ZTIN6mysqlx4abi22r05ValueE]+0x28): undefined reference to `typeinfo for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

anybody knows what to do ?

Options: ReplyQuote


Subject
Views
Written By
Posted
cmake error when using xdevapi
1115
November 20, 2022 04:39AM
469
November 21, 2022 05:55AM
308
November 21, 2022 09:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.