【发布时间】:2017-01-11 16:19:30
【问题描述】:
我似乎找不到我的 CMake 问题的解决方案。
我想使用 mysql-connector-c++ 和 CURL,在我的 /Desktop/example 目录中我制作了以下 CMakeLists.txt:
cmake_minimum_required (VERSION 3.1.0)
PROJECT (main)
ADD_EXECUTABLE (main main.cpp)
target_link_libraries(main curl mysql-connector-c++)
target_compile_features(main PRIVATE cxx_range_for)
我在 main.cpp 中包含了以下标头:
#include <curl/curl.h>
#include <mysql_connection.h>
#include <driver.h>
#include <exception.h>
#include <resultset.h>
#include <statement.h>
我已经下载了 mysql-connector-c++ 的 zip file,解压缩并将其放在我的当前目录中。
然后我运行 cmake . 和 make 并生成以下错误:
fatal error:
'mysql_connection.h' file not found
这很奇怪,因为当我删除 mysql-connector 标头时,CURL 工作正常。
关于为什么这不起作用的任何想法?
注意 以下命令运行并显示所述结果:
g++ -std=c++14 -lcurl main.cpp //Success
g++ -std=c++14 -lcurl -lmysqlcppconn main.cpp //Fatal eror: 'mysql_connection.h' file not found
【问题讨论】:
-
你把解压后的存档放在
Desktop/example里面了吗? -
@fedepad 应该不是解压后的
mysql-connector-c++? -
不用了,我正在写一个你可以试试的答案...
标签: c++ macos cmake mysql-connector