报错信息:
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要适当更改!!!!!
include_directories(/usr/include/mysql)
target_link_libraries(test.app mysqlclient)
其它问题:
如有其它问题,请先排查是否正确安装MySQL和API:
API 安装:
sudo apt-get update
sudo apt-get install libmysql++-dev
sudo apt-get install libmysqlclient-dev