Библиотеки Poco ставились при помощи conan и cmake, IDE может перейти к коду библиотеки, но у линковщика с ней проблемы. Основные причины данной проблемы проверил, не помогло. Библиотека устанавливалась poco, должна подходить.
#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;
}
Для SQLite все работает хорошо, но если сменить в коде SQLite на MySQL, make не справляется. Текст ошибки:
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
после применения ответа @isnullxbh ругается так:
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
а старая так:
/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
После того, как Вы выполните команду conan install ..., в исходной директории появится файл conanbuildinfo.cmake - так вот, Вам нужно подключить его через include в cmake-файле, например:
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
Затем указать директории с установленными библиотеками:
target_link_directories(${PROJECT_NAME} PRIVATE
${CONAN_LIB_DIRS})
И слинковаться с ними:
target_link_libraries(${PROJECT_NAME} PRIVATE
${CONAN_LIBS})
UPD.:
В секцию options добавьте строчку:
Poco:enable_data_mysql=True
Посмотреть список опций можно здесь.
Продвижение своими сайтами как стратегия роста и независимости