soci gives fatal error: mysql.h: No such file or directory

soci gives fatal error: mysql.h: No such file or directory

当我尝试编译一个使用 SOCI 库的程序时,我得到:

/usr/local/include/soci/mysql/soci-mysql.h:31:10: fatal error: mysql.h: No such file or directory

我检查过 mysql.h 在:

/usr/include/mysql

我的 CMakeLists 文件是:

cmake_minimum_required(VERSION 3.10)

add_definitions(-DUNICODE -D_UNICODE)
project(server)

find_package(Threads REQUIRED)

include_directories(include
                    ../Third-party/SimpleIni
                    ../Shared/Logger
                    ../Shared/Communication-Protocol     
)

file(GLOB SOURCES "src/*.cpp")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin)
add_executable(${PROJECT_NAME} ${SOURCES})

set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
target_link_libraries(${PROJECT_NAME} pthread soci_core soci_mysql)

target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)

我尝试添加:

find_package(mysql REQUIRED)
include_directories (${MYSQL_INCLUDE_DIR})

但是我知道没有包配置文件。

我还尝试重新安装 soci 和 mysql 连接器。

我用这个解决了这个问题:https://github.com/Gancc123/flame-sp/blob/c8108823dea205e25abac03942534996710109f3/cmake/modules/Findmysql.cmake