I am new and was trying to learn xdevapi for MySQL. i wanted to use it with C++ code on my windows device. but i am having a hard time running sample code. and i am getting a lot of linker errors. there is not much online about these building configuration. and similar queries on internet doesn't have replies.
here is my code:
#include <iostream>
#include <mysqlx/xdevapi.h>
using namespace mysqlx;
// Scope controls life-time of objects such as session or schema
int main(void) {
Session mySession("mysqlx://localhost:33060/testdb?user=test&password=test");
std::list<Schema> schemaList = mySession.getSchemas();
std::cout << "Available schemas in this session:" << std::endl;
// Loop over all available schemas and print their name
for (Schema schema : schemaList) {
std::cout << schema.getName() << std::endl;
}
}
Makefile
MYSQL_CONCPP_DIR = C:/Program Files/MySQL/Connector C++ 8.0
CPPFLAGS = -I "$(MYSQL_CONCPP_DIR)/include" -L "$(MYSQL_CONCPP_DIR)/lib64"
LDLIBS = -lvs14/mysqlcppconn8 -lssleay32 -llibeay32 -lpthread
CXXFLAGS = -Wall -g3 -std=c++11
test: test.cpp
compiler Output:
g++ -Wall -g3 -std=c++11 -I "C:/Program Files/MySQL/Connector C++ 8.0/include" -L "C:/Program Files/MySQL/Connector C++ 8.0/lib64" test.cpp -lvs14/mysqlcppconn8 -lssleay32 -llibeay32 -lpthread -o test
In file included from C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/common.h:35,
from C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/xdevapi.h:91,
from test.cpp:3:
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/common.h:60: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(lib,"ws2_32")
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::string::string(char const*)':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/common.h:110: undefined reference to `mysqlx::string::Impl::from_utf8(mysqlx::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::string::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >() const':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/common.h:125: undefined reference to `mysqlx::string::Impl::to_utf8[abi:cxx11](mysqlx::string const&)'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::Value::print(std::ostream&) const':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/document.h:506: undefined reference to `mysqlx::common::Value::print(std::ostream&) const'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::SessionSettings::SessionSettings(mysqlx::string const&)':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/settings.h:293: undefined reference to `mysqlx::common::Settings_impl::set_from_uri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::internal::Session_detail::Name_src::~Name_src()':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/detail/session.h:271: undefined reference to `mysqlx::internal::Query_src::~Query_src()'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::internal::Session_detail::Name_src::~Name_src()':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/detail/session.h:271: undefined reference to `mysqlx::internal::Query_src::~Query_src()'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::internal::Session_detail::Schema_src::Schema_src(mysqlx::Session&, mysqlx::string const&)':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/detail/session.h:284: undefined reference to `mysqlx::internal::Session_detail::Name_src::Name_src(mysqlx::Session const&, mysqlx::string const&)'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::internal::Session_detail::~Session_detail()':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/detail/session.h:321: undefined reference to `mysqlx::internal::Session_detail::close()'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::internal::Session_detail::~Session_detail()':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/detail/session.h:321: undefined reference to `mysqlx::internal::Session_detail::close()'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::Session::Session(mysqlx::SessionSettings)':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/xdevapi.h:1101: undefined reference to `mysqlx::internal::Session_detail::Session_detail(mysqlx::common::Settings_impl&)'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::internal::Iterator<mysqlx::internal::Session_detail::Schema_src, mysqlx::Schema, long long, mysqlx::Schema*, mysqlx::Schema&>::Iterator(mysqlx::internal::Session_detail::Schema_src&)':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/common.h:335: undefined reference to `mysqlx::internal::Query_src::iterator_next()'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::internal::Iterator<mysqlx::internal::Session_detail::Schema_src, mysqlx::Schema, long long, mysqlx::Schema*, mysqlx::Schema&>::operator++()':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/common.h:355: undefined reference to `mysqlx::internal::Query_src::iterator_next()'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o: In function `mysqlx::internal::Iterator<mysqlx::internal::Session_detail::Schema_src, mysqlx::Schema, long long, mysqlx::Schema*, mysqlx::Schema&>::operator*() const':
C:/Program Files/MySQL/Connector C++ 8.0/include/mysqlx/devapi/common.h:367: undefined reference to `mysqlx::internal::Session_detail::Schema_src::iterator_get()'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o:test.cpp:(.rdata$_ZTCN6mysqlx5ValueE0_NS_6common5ValueE[_ZTCN6mysqlx5ValueE0_NS_6common5ValueE]+0x20): undefined reference to `mysqlx::common::Value::print(std::ostream&) const'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o:test.cpp:(.rdata$.refptr._ZTVN6mysqlx8internal9Query_srcE[.refptr._ZTVN6mysqlx8internal9Query_srcE]+0x0): undefined reference to `vtable for mysqlx::internal::Query_src'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o:test.cpp:(.rdata$.refptr._ZTVN6mysqlx5DbDocE[.refptr._ZTVN6mysqlx5DbDocE]+0x0): undefined reference to `vtable for mysqlx::DbDoc'
C:\Users\sirea\AppData\Local\Temp\ccBh6psQ.o:test.cpp:(.rdata$.refptr._ZTVN6mysqlx6common5ValueE[.refptr._ZTVN6mysqlx6common5ValueE]+0x0): undefined reference to `vtable for mysqlx::common::Value'
collect2.exe: error: ld returned 1 exit status
make: *** [<builtin>: test] Error 1
directory tree connector folder
Folder PATH listing for volume OS
Volume serial number is 1E28-BDAE
C:.
| BUILDINFO.txt
| LICENSE.txt
| README.txt
| res
|
+---include
| +---jdbc
| | | mysql_connection.h
| | | mysql_driver.h
| | | mysql_error.h
| | |
| | \---cppconn
| | build_config.h
| | config.h
| | connection.h
| | datatype.h
| | driver.h
| | exception.h
| | metadata.h
| | parameter_metadata.h
| | prepared_statement.h
| | resultset.h
| | resultset_metadata.h
| | sqlstring.h
| | statement.h
| | variant.h
| | version_info.h
| | warning.h
| |
| \---mysqlx
| | common.h
| | common_constants.h
| | xapi.h
| | xdevapi.h
| |
| +---common
| | api.h
| | error.h
| | op_if.h
| | settings.h
| | util.h
| | value.h
| |
| \---devapi
| | collations.h
| | collection_crud.h
| | common.h
| | crud.h
| | document.h
| | error.h
| | executable.h
| | mysql_charsets.h
| | mysql_collations.h
| | result.h
| | row.h
| | settings.h
| | table_crud.h
| |
| \---detail
| crud.h
| error.h
| result.h
| row.h
| session.h
| settings.h
|
\---lib64
| libeay32.dll
| mysqlcppconn-7-vs14.dll
| mysqlcppconn8-1-vs14.dll
| ssleay32.dll
|
\---vs14
libeay32.lib
mysqlcppconn-static.lib
mysqlcppconn.lib
mysqlcppconn8-static.lib
mysqlcppconn8.lib
ssleay32.lib
i am using 8.12 version