CLion如何添加依赖库 ? 需要把mysql/Connector c++放入 用cpp连接数据库
怪我咯
怪我咯 2017-04-17 13:38:59
0
2
1349

目前我把下载的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

文件引用情况如下:

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

怪我咯
怪我咯

走同样的路,发现不同的人生

全部回覆(2)
巴扎黑

他不是都提示你用""而不是了麼

另外, 你貌似用了CMake, 那你把庫的路徑加到include路徑裡面去. 比如說deps路徑下有mysql文件夾, 我代碼裡面要寫#include <mysql/mysql.h>, 那麼在cmake裡面寫INCLUDE_DIRECTORIES(deps)

小葫芦

這兒有一個CMake module用來找mysql connector
https://github.com/windoze/fibio/blob/master/cmake/Modules/FindMySQLConnectorCPP.cmake
然後你就可以寫find_package(MySQLConnectorCPP)

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板