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
相关推荐
李广坤3 小时前
MySQL 大表字段变更实践(改名 + 改类型 + 改长度)
数据库
Turnip12021 天前
深度解析:为什么简单的数据库"写操作"会在 MySQL 中卡住?
后端·mysql
爱可生开源社区1 天前
2026 年,优秀的 DBA 需要具备哪些素质?
数据库·人工智能·dba
随逸1771 天前
《从零搭建NestJS项目》
数据库·typescript
加号32 天前
windows系统下mysql多源数据库同步部署
数据库·windows·mysql
シ風箏2 天前
MySQL【部署 04】Docker部署 MySQL8.0.32 版本(网盘镜像及启动命令分享)
数据库·mysql·docker
李慕婉学姐2 天前
Springboot智慧社区系统设计与开发6n99s526(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·spring boot·后端
百锦再2 天前
Django实现接口token检测的实现方案
数据库·python·django·sqlite·flask·fastapi·pip
WeiXin_DZbishe2 天前
基于django在线音乐数据采集的设计与实现-计算机毕设 附源码 22647
javascript·spring boot·mysql·django·node.js·php·html5
tryCbest2 天前
数据库SQL学习
数据库·sql