MySQL Forums
Forum List  »  Connector/C++

Re: Static linking to Connector/C++ on linux giving errors
Posted by: Pelle Stormark
Date: April 14, 2020 05:09AM

dpkg -l | grep libmysql gives me the following:

ii libmysqlclient-dev 5.7.29-0ubuntu0.18.04.1 amd64 MySQL database development files
ii libmysqlclient20:amd64 5.7.29-0ubuntu0.18.04.1 amd64 MySQL database client library
ii libmysqlcppconn-dev:amd64 8.0.19-1ubuntu18.04 amd64 Development header files and libraries for MySQL C++ client applications
ii libmysqlcppconn7:amd64 8.0.19-1ubuntu18.04 amd64 MySQL Driver for C++ which mimics the JDBC 4.0 API
ii libmysqlcppconn7-dbgsym:amd64 8.0.19-1ubuntu18.04 amd64 debug symbols for libmysqlcppconn7
ii libmysqlcppconn8-2:amd64 8.0.19-1ubuntu18.04 amd64 MySQL database connector for C++
ii libmysqlcppconn8-2-dbgsym:amd64 8.0.19-1ubuntu18.04 amd64 debug symbols for libmysqlcppconn8-2

This should be correct. I removed the 32-bit and installed the missing ones. The 32-bit package might have been the reason for dynamic linking not working. I still get the following error when linking statically:

/tmp/ccc6BRyC.o: In function `mysqlx::abi2::r0::string::traits<char>::to_str[abi:cxx11](mysqlx::abi2::r0::string const&)':
main.cc:(.text._ZN6mysqlx4abi22r06string6traitsIcE6to_strB5cxx11ERKS2_[_ZN6mysqlx4abi22r06string6traitsIcE6to_strB5cxx11ERKS2_]+0x2e): undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
collect2: error: ld returned 1 exit status

I'm using this compiler statement:

g++ main.cc -o test -I /usr/include/mysql-cppconn-8/include /usr/include/mysql-cppconn-8/lib64/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread -lresolv

So, the error here doesn't seem to be related to the packages mentioned. Any idea?

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Static linking to Connector/C++ on linux giving errors
239
April 14, 2020 05:09AM


Sorry, only registered users may post in this forum.

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.