CLion如何添加依赖库 ? 需要把mysql/Connector c++放入 用cpp连接数据库

发布于 2022-09-01 23:38:19 字数 2560 浏览 59 评论 0

目前我把下载的mysql/Connector 下载后放在了project内 但是报错信息如下
报错信息如下

In file included from /Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlConnection.h:/Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlFiles/include/mysql_connection.h7::
15:/Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlFiles/include/mysql_connection.h10::15 :10: error: error: 'cppconn/connection.h' file not found with <angled> include; use "quotes" instead'cppconn/connection.h' file not found with <angled> include; use "quotes" instead

#include <cppconn/connection.h>#include <cppconn/connection.h>

         ^~~~~~~~~~~~~~~~~~~~~~
         ^~~~~~~~~~~~~~~~~~~~~~         "cppconn/connection.h"

         "cppconn/connection.h"
In file included from In file included from /Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlConnection.cpp:5:
In file included from /Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlConnection.h:8:
/Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlFiles/include/mysql_driver.h/Users/wsgdrfz/study/c++/Libary_System/librarySystem/main.cpp::152::
10In file included from :/Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlConnection.h :8:
error: /Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlFiles/include/mysql_driver.h:15'cppconn/driver.h' file not found with <angled> include; use "quotes" instead:10
: error: 'cppconn/driver.h' file not found with <angled> include; use "quotes" instead
#include <cppconn/driver.h>
         ^~~~~~~~~~~~~~~~~~
#include <cppconn/driver.h>         "cppconn/driver.h"

         ^~~~~~~~~~~~~~~~~~
         "cppconn/driver.h"
/Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlConnection.cpp:28:12: error: calling a protected destructor of class 'sql::Driver'
    delete driver;
           ^
/Users/wsgdrfz/study/c++/Libary_System/librarySystem/sqlFiles/include/cppconn/driver.h:26:10: note: declared protected here
        virtual ~Driver() {}
                ^
2 errors generated.
3 errors generated.
make[2]: *** [CMakeFiles/librarySystem.dir/main.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/librarySystem.dir/sqlConnection.cpp.o] Error 1
make[1]: *** [CMakeFiles/librarySystem.dir/all] Error 2
make: *** [all] Error 2

文件引用情况如下:
6a8020f7gw1ezgizwk2naj20q40awdhz.jpg

在网上搜索有很多连接的方法 目前还是有点晕 望指教

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软糖 2022-09-08 23:38:19

他不是都提示你用""而不是<>了么

另外, 你貌似用了CMake, 那你把库的路径加到include路径里面去. 比如说deps路径下有mysql文件夹, 我代码里面要写#include <mysql/mysql.h>, 那么在cmake里面写INCLUDE_DIRECTORIES(deps)

怎会甘心 2022-09-08 23:38:19

这儿有一个CMake module用来找mysql connector
https://github.com/windoze/fibio/blob/master/cmake/Modules/FindMySQLConnectorCPP.cmake
然后你就可以写find_package(MySQLConnectorCPP)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文