1

I am trying to compile a c++ file, but the compiler seems to be missing some files for the mysql c++ connector. This is how I'm trying to compile it:

g++ -I /usr/local/boost_1_70_0 -L /usr/local/boost_1_70_0 -I /usr/include/mysql-cppconn-8 -pthread -std=c++2a `pkg-config gtkmm-3.0 --cflags --libs` srv.cpp -o srv

One of the lines in the error message is

undefined reference to 
`mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11] 
(mysqlx::abi2::r0::string const&)'
/tmp/ccf90UaW.o: In function `mysqlx::abi2::r0::DbDoc::DbDoc()'

It seems to be this file which tries to find some unlinked code: .../mysqlx/xdevapi.h Can someone point me in the right direction as to where the necessary files are? It seems like there are some important files that haven't been linked yet.

6
  • When building, the libraries to link with needs to be placed after any source or object files. So move the pkg-config invocation to the end of the command line. Commented Jul 19, 2019 at 13:25
  • Thank you for the info, but still the same error messages. Commented Jul 19, 2019 at 13:38
  • Where in that command have you linked the MySQL connector library? Commented Jul 19, 2019 at 13:55
  • Here's the documentation for using the MySQL connector in C++ Commented Jul 19, 2019 at 13:57
  • I thought I only needed to tell the compiler where the headers were located Commented Jul 19, 2019 at 14:16

1 Answer 1

1

Took me some time to figure this out. Managed to fix it by changing the makefile to this:

MYSQL_CONCPP_DIR = /usr/include/mysql-cppconn-8
BOOST_DIR = /usr/local/boost_1_70_0
CPPFLAGS = -I $(MYSQL_CONCPP_DIR) -L $(MYSQL_CONCPP_DIR) -I $(BOOST_DIR) -L 
$(BOOST_DIR)
LDLIBS = -lmysqlcppconn8 -lpthread
CXXFLAGS = -std=c++11 `pkg-config gtkmm-3.0 --cflags --libs`
srv: srv.cpp
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.