ubuntu22.04 cmake 配置mysql

报错信息:

CMake Error at CMakeLists.txt:33 (find_package):

By not providing "FindMySQL.cmake" in CMAKE_MODULE_PATH this project has

asked CMake to find a package configuration file provided by "MySQL", but

CMake did not find one.

Could not find a package configuration file provided by "MySQL" with any of

the following names:

复制代码
MySQLConfig.cmake
mysql-config.cmake

Add the installation prefix of "MySQL" to CMAKE_PREFIX_PATH or set

"MySQL_DIR" to a directory containing one of the above files. If "MySQL"

provides a separate development package or SDK, be sure it has been

installed.

解决方法:

cmakelist中,添加类似的语句:
!!!!!其中/usr/include/mysql 和 test.app要适当更改!!!!!

cpp 复制代码
include_directories(/usr/include/mysql)
target_link_libraries(test.app mysqlclient)

其它问题:

如有其它问题,请先排查是否正确安装MySQL和API:

API 安装:

bash 复制代码
sudo apt-get update
sudo apt-get install libmysql++-dev
sudo apt-get install libmysqlclient-dev
相关推荐
DBA小马哥26 分钟前
时序数据库迁移替换与时序数据库分片
数据库·时序数据库
DBA小马哥27 分钟前
时序数据库迁移方案在物联网设备监测中的实践与性能突破
数据库·物联网·时序数据库
ID_1800790547327 分钟前
小红书笔记详情API接口基础解析:数据结构与调用方式
数据结构·数据库·笔记
ruleslol6 小时前
MySQL的段、区、页、行 详解
数据库·mysql
天若有情6736 小时前
校园二手交易系统实战开发全记录(vue+SpringBoot+MySQL)
vue.js·spring boot·mysql
while(1){yan}6 小时前
MyBatis Generator
数据库·spring boot·java-ee·mybatis
それども7 小时前
MySQL affectedRows 计算逻辑
数据库·mysql
是小章啊7 小时前
MySQL 之SQL 执行规则及索引详解
数据库·sql·mysql
富士康质检员张全蛋7 小时前
JDBC 连接池
数据库
yangminlei7 小时前
集成Camunda到Spring Boot项目
数据库·oracle