Skip to content
Advertisement

Poco C++ Libraries: “Not found: mysql”

I am using poco-1.7.7 with MySQL. I am building with g++ on Ubuntu. Building, linking and running works fine. However, when a Data Session is created, an exception “Not found: mysql” is thrown:

std::string str = Poco::format("host=%s;user=%s;password=%s;compress=true;auto-reconnect=true;secure-auth=true", _mySQLParams.host, _mySQLParams.user, _mySQLParams.password);
_session = new Poco::Data::Session(Poco::Data::SessionFactory::instance().create(Poco::Data::MySQL::Connector::KEY, str));

The mysql client is installed and is part of $PATH.

Additional information: I am running Ubuntu using Docker. See below for Makefile. The same code can connect to MySQL when I compile and run on MacOSX.

Do you have any idea what is going wrong here?

Snippet from Makefile:

CXX=g++
HEADER_SEARCH_PATH=-I"../../Core/Application/" -I"../../Core/Model/" -I"../../Core/Object/" -I"../../Core/UserInterface/" -I"/usr/local/include/" -I"/usr/include/mysql"
LIB_SEARCH_PATH=-L/usr/local/lib -L/usr/lib/x86_64-linux-gnu
LIBS=-l"PocoJSON" -l"PocoXML" -l"PocoUtil" -l"PocoNet" -l"PocoFoundation" -l"crypto" -l"ssl" -l"PocoCrypto" -l"PocoData" -l"PocoDataMySQL" `pkg-config --libs --cflags icu-uc icu-io`
PPD=-DMPS_MYSQL=1
CXXFLAGS=-std=c++11 -g -m64 -pthread -Wl,--verbose -fabi-version=2 -fno-omit-frame-pointer $(HEADER_SEARCH_PATH) $(PPD)

Advertisement

Answer

After a lot of debugging i found out, that for some reason the MySQL Connector was not initialized. Explicitly calling Poco::Data::MySQL::Connector::registerConnector(); solved the problem.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement