Poco libraries were installed using conan and cmake, IDE can go to the library code, but the linker has problems with it. The main causes of this problem checked, did not help. The library was installed by poco, must be appropriate.
#include <iostream> #include <Poco/Data/Session.h> #include <Poco/Data/MySQL/Connector.h> int main(){ Poco::Data::MySQL::Connector::registerConnector(); Poco::Data::Session session{"MySQL", "host=localhost;port=3306;db=statsDB;user=user;password=pass"}; return 0; } For SQLite, everything works fine, but if you change it in SQLite code to MySQL, make fails. Error text:
CMakeFiles/ISPstats.dir/main.cpp.o: In function `main': main.cpp:(.text+0x13): undefined reference to `Poco::Data::MySQL::Connector::registerConnector()' main.cpp:(.text+0x128): undefined reference to `Poco::Data::Session::Session(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long)' main.cpp:(.text+0x155): undefined reference to `Poco::Data::Session::~Session()' clang: error: linker command failed with exit code 1 (use -v to see invocation) CMakeFiles/ISPstats.dir/build.make:94: recipe for target 'ISPstats' failed make[3]: *** [ISPstats] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ISPstats.dir/all' failed make[2]: *** [CMakeFiles/ISPstats.dir/all] Error 2 CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/ISPstats.dir/rule' failed make[1]: *** [CMakeFiles/ISPstats.dir/rule] Error 2 Makefile:129: recipe for target 'ISPstats' failed make: *** [ISPstats] Error 2 after applying the answer, @isnullxbh swears like this:
CMakeFiles/ISPstats.dir/main.cpp.o: In function `main': /home/nerd/CLionProjects/ISPstats/main.cpp:6: undefined reference to `Poco::Data::MySQL::Connector::registerConnector()' clang: error: linker command failed with exit code 1 (use -v to see invocation) CMakeFiles/ISPstats.dir/build.make:83: recipe for target 'ISPstats' failed make[2]: *** [ISPstats] Error 1 CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/ISPstats.dir/all' failed make[1]: *** [CMakeFiles/ISPstats.dir/all] Error 2 Makefile:94: recipe for target 'all' failed make: *** [all] Error 2 and the old way:
/usr/bin/ld: cannot find -lPocoMongoDB /usr/bin/ld: cannot find -lPocoNet /usr/bin/ld: cannot find -lPocoNetSSL /usr/bin/ld: cannot find -lPocoCrypto /usr/bin/ld: cannot find -lPocoData /usr/bin/ld: cannot find -lPocoDataSQLite /usr/bin/ld: cannot find -lPocoZip /usr/bin/ld: cannot find -lPocoUtil /usr/bin/ld: cannot find -lPocoXML /usr/bin/ld: cannot find -lPocoJSON /usr/bin/ld: cannot find -lPocoFoundation clang: error: linker command failed with exit code 1 (use -v to see invocation) CMakeFiles/ISPstats.dir/build.make:94: recipe for target 'ISPstats' failed make[2]: *** [ISPstats] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ISPstats.dir/all' failed make[1]: *** [CMakeFiles/ISPstats.dir/all] Error 2 Makefile:94: recipe for target 'all' failed make: *** [all] Error 2