1

When I am trying to compile a program that is using SOCI library I get:

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

I've checked and I have mysql.h in:

/usr/include/mysql

My CMakeLists file is:

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)

I've tried to add:

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

but I get that there is no package configuration file.

I've also tried to reinstall soci and mysql connector.

Shadow
  • 33,525
  • 10
  • 51
  • 64
  • Have a look at e.g. https://gist.github.com/RenatoUtsch/1623340. Might be outdated but there is no support for `find_package(mysql)` built into CMake. – Peter Aug 15 '20 at 14:45
  • Thanks. That particular script didn't worked but I've found one here:https://github.com/Gancc123/flame-sp/blob/c8108823dea205e25abac03942534996710109f3/cmake/modules/Findmysql.cmake – Robert-Nicolae Solca Aug 15 '20 at 15:58

1 Answers1