soci: fatal error: 'mysql.h' file not found

clone soci into /Users/alexey/CLionProjects/untitled1/lib/soci with terminal git clone and write a CMakeLists.txt as in example/subdir-include/CMakeLists.txt

Here is my CMakeLists.txt:

project(untitled1)

set(CMAKE_CXX_STANDARD 17)
set(SOCI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/soci)

find_package(Soci REQUIRED)

option(SOCI_MYSQL "Build the sample backend called MySQL" ON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/soci ${SOCI_BINARY_DIR})

add_executable(untitled1 untitled1.cpp)

target_link_libraries(untitled1 soci_core soci_mysql)

Here is my error:

/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake --build /Users/alexey/CLionProjects/untitled1/cmake-build-debug --target untitled1 -j 6
[0/1] Re-running CMake...
-- Found Boost: /opt/homebrew/lib/cmake/Boost-1.85.0/BoostConfig.cmake (found version "1.85.0")  
-- Found Boost: /opt/homebrew/lib/cmake/Boost-1.85.0/BoostConfig.cmake (found suitable version "1.85.0", minimum required is "1.55.0") found components: system filesystem 
-- gcc / clang visibility enabled
-- Configuring SOCI: 
-- SOCI_VERSION                             = 4.1.0 
-- SOCI_ABI_VERSION                         = 4.1 
-- SOCI_SHARED                              = ON 
-- SOCI_STATIC                              = ON 
-- SOCI_TESTS                               = ON 
-- SOCI_ASAN                                = OFF 
-- LIB_SUFFIX                               =  
-- Looking for SOCI dependencies: 
-- Threads: 
-- CMAKE_THREAD_LIBS_INIT                   =  
-- Boost: 
-- BOOST_RELEASE_VERSION                    =  
-- BOOST_INCLUDE_DIR                        =  
-- BOOST_LIBRARIES                          =  
-- MySQL: 
-- Found MySQL: /opt/homebrew/include/mysql, /opt/homebrew/lib/libmysqlclient.dylib
-- MYSQL_INCLUDE_DIR                        = /opt/homebrew/include/mysql 
-- MYSQL_LIBRARIES                          = /opt/homebrew/lib/libmysqlclient.dylib 
-- ODBC: 
-- WARNING: ODBC libraries not found, some features will be disabled. 
-- Oracle: 
-- ORACLE_HOME=
-- None of the supported Oracle versions (21;20;19;18;12;11;10) could be found, consider updating ORACLE_VERSIONS if the version you use is not among them.
-- WARNING: Oracle libraries not found, some features will be disabled. 
-- PostgreSQL: 
-- WARNING: PostgreSQL libraries not found, some features will be disabled. 
-- SQLite3: 
-- SQLITE3_INCLUDE_DIR                      = /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include 
-- SQLITE3_LIBRARIES                        = /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/lib/libsqlite3.tbd 
-- Firebird: 
-- SOCI_FIREBIRD_EMBEDDED                   = OFF 
-- WARNING: Firebird libraries not found, some features will be disabled. 
-- DB2: 
-- WARNING: DB2 libraries not found, some features will be disabled. 
-- Configuring SOCI core library: 
-- SOCI_CORE_TARGET                         = soci_core 
-- SOCI_CORE_TARGET_OUTPUT_NAME             = soci_core 
-- SOCI_CORE_DEPS_LIBS                      = /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/lib/libdl.tbd Boost::date_time 
-- SOCI_CORE_INCLUDE_DIRS                   = /Users/alexey/CLionProjects/untitled1/lib/soci/cmake /opt/homebrew/include /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci /Users/alexey/CLionProjects/untitled1/lib/soci/include /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci/include /Users/alexey/CLionProjects/untitled1/lib/soci/include/private /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci/src/core 
-- WITH_BOOST                               = ON 
-- COMPILE_DEFINITIONS                      = SOCI_ABI_VERSION="4.1" HAVE_DL=1 BOOST_ALL_NO_LIB SOCI_LIB_PREFIX="libsoci_" SOCI_LIB_SUFFIX=".dylib" SOCI_DEBUG_POSTFIX="" 
-- 
-- Configuring SOCI backend libraries: 
-- Found MySQL: /opt/homebrew/include/mysql, /opt/homebrew/lib/libmysqlclient.dylib
-- ORACLE_HOME=
-- None of the supported Oracle versions (21;20;19;18;12;11;10) could be found, consider updating ORACLE_VERSIONS if the version you use is not among them.
-- Empty - SOCI backend skeleton for new backends development 
-- SOCI_EMPTY                               = ON 
-- SOCI_EMPTY_TARGET                        = soci_empty 
-- SOCI_EMPTY_OUTPUT_NAME                   = soci_empty 
-- SOCI_EMPTY_COMPILE_DEFINITIONS           = SOCI_ABI_VERSION="4.1" HAVE_DL=1 BOOST_ALL_NO_LIB 
-- SOCI_EMPTY_INCLUDE_DIRECTORIES           = /Users/alexey/CLionProjects/untitled1/lib/soci/cmake /opt/homebrew/include /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci /Users/alexey/CLionProjects/untitled1/lib/soci/include /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci/include /Users/alexey/CLionProjects/untitled1/lib/soci/include/private /Users/alexey/CLionProjects/untitled1/lib/soci/include/private 
-- MySQL - SOCI backend for MySQL 
-- SOCI_MYSQL                               = ON 
-- SOCI_MYSQL_TARGET                        = soci_mysql 
-- SOCI_MYSQL_OUTPUT_NAME                   = soci_mysql 
-- SOCI_MYSQL_COMPILE_DEFINITIONS           = SOCI_ABI_VERSION="4.1" HAVE_DL=1 BOOST_ALL_NO_LIB 
-- SOCI_MYSQL_INCLUDE_DIRECTORIES           = /Users/alexey/CLionProjects/untitled1/lib/soci/cmake /opt/homebrew/include /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci /Users/alexey/CLionProjects/untitled1/lib/soci/include /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci/include /Users/alexey/CLionProjects/untitled1/lib/soci/include/private /Users/alexey/CLionProjects/untitled1/lib/soci/include/private /opt/homebrew/include/mysql 
-- SQLite3 - SOCI backend for SQLite 3 
-- SOCI_SQLITE3                             = ON 
-- SOCI_SQLITE3_TARGET                      = soci_sqlite3 
-- SOCI_SQLITE3_OUTPUT_NAME                 = soci_sqlite3 
-- SOCI_SQLITE3_COMPILE_DEFINITIONS         = SOCI_ABI_VERSION="4.1" HAVE_DL=1 BOOST_ALL_NO_LIB 
-- SOCI_SQLITE3_INCLUDE_DIRECTORIES         = /Users/alexey/CLionProjects/untitled1/lib/soci/cmake /opt/homebrew/include /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci /Users/alexey/CLionProjects/untitled1/lib/soci/include /Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci/include /Users/alexey/CLionProjects/untitled1/lib/soci/include/private /Users/alexey/CLionProjects/untitled1/lib/soci/include/private /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include 
-- 
-- Configuring SOCI tests: 
-- SOCI_EMPTY_TEST_CONNSTR                  = dummy
-- SOCI_MYSQL_TEST_CONNSTR                  = db=soci_test
-- MS Access test disabled on non-Windows platform
-- ODBC DB2 test disabled.
-- SOCI_SQLITE3_TEST_CONNSTR                = :memory:
-- 
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/alexey/CLionProjects/untitled1/cmake-build-debug
[2/6] Linking CXX shared library lib/libsoci_mysql.4.1.0.dylib
ld: warning: -undefined suppress is deprecated
[4/6] Building CXX object CMakeFiles/untitled1.dir/untitled1.cpp.o
FAILED: CMakeFiles/untitled1.dir/untitled1.cpp.o 
/Library/Developer/CommandLineTools/usr/bin/c++ -DBOOST_DATE_TIME_DYN_LINK -DBOOST_DATE_TIME_NO_LIB -I/Users/alexey/CLionProjects/untitled1/lib/soci/cmake -I/Users/alexey/CLionProjects/untitled1/lib/soci/src/core/../../include -I/Users/alexey/CLionProjects/untitled1/cmake-build-debug/soci/src/core/../../include -isystem /opt/homebrew/include -g -std=gnu++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -fcolor-diagnostics -MD -MT CMakeFiles/untitled1.dir/untitled1.cpp.o -MF CMakeFiles/untitled1.dir/untitled1.cpp.o.d -o CMakeFiles/untitled1.dir/untitled1.cpp.o -c /Users/alexey/CLionProjects/untitled1/untitled1.cpp
In file included from /Users/alexey/CLionProjects/untitled1/untitled1.cpp:2:
/Users/alexey/CLionProjects/untitled1/lib/soci/src/core/../../include/soci/mysql/soci-mysql.h:38:10: fatal error: 'mysql.h' file not found
#include <mysql.h> // MySQL Client
         ^~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.```

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Maybe we have to install the FindMySQL module along with SOCI in order for it to find that

This is now done in the latest version of my PR. Hopefully this also resolves the issue on your system πŸ‘€

OK, I removed FindSOCI, used find_package(SOCI REQUIRED) in CMakeLists.txt of xeus-sql. It now takes SOCIConfigSOCI.make from SOCI project, but fails.

Hello, I try again, now with adding some verbosity:

-- Found Boost: /usr/lib64/cmake/Boost-1.86.0/BoostConfig.cmake (found version "1.86.0") found components: date_time
-- Found MySQL: /usr/lib64/libmysqlclient.so
-- Found ODBC: /usr/lib64/libodbc.so
-- Found PostgreSQL: /usr/lib64/libpq.so (found version "17.0")
-- Found SQLite3: /usr/include (found version "3.46.1")
[...]
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(98):  if(TARGET MySQL::MySQL )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(100):  else()
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(101):  set(__already_found OFF )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(102):  break()
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(106):  if(__already_found )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(110):  if(__components )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(114):  if(SOCI_FIND_QUIETLY )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(116):  else()
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(117):  set(__quiet  )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(120):  find_package(MySQL   )
-- Found MySQL: /usr/lib64/libmysqlclient.so
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(126):  if(NOT MySQL_FOUND )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(127):  if(__required )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(128):  set(SOCI_FOUND FALSE )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(129):  set(SOCI_NOT_FOUND_MESSAGE Unmet dependency 'MySQL' for SOCI component 'MySQL' )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(130):  set(__skip_dependency TRUE )
/usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake(132):  continue()
[...]
CMake Error at CMakeLists.txt:69 (find_package):
  Found package configuration file:
    /usr/lib64/cmake/soci-4.1.0/SOCIConfig.cmake
  but it set SOCI_FOUND to FALSE so package "SOCI" is considered to be NOT
  FOUND.  Reason given by package:
  Unmet dependency 'MySQL' for SOCI component 'MySQL'

MySQL is said found, but the variable MySQL_FOUND is false or not set.

Okay that was easy. It’s fixed already:

    └── soci
        β”œβ”€β”€ libsoci_core.so -> libsoci_core.so.4
        β”œβ”€β”€ libsoci_core.so.4 -> libsoci_core.so.4.1.0
        β”œβ”€β”€ libsoci_core.so.4.1.0
        β”œβ”€β”€ libsoci_empty.so -> libsoci_empty.so.4
        β”œβ”€β”€ libsoci_empty.so.4 -> libsoci_empty.so.4.1.0
        β”œβ”€β”€ libsoci_empty.so.4.1.0
        β”œβ”€β”€ libsoci_firebird.so -> libsoci_firebird.so.4
        β”œβ”€β”€ libsoci_firebird.so.4 -> libsoci_firebird.so.4.1.0
        β”œβ”€β”€ libsoci_firebird.so.4.1.0
        β”œβ”€β”€ libsoci_mysql.so -> libsoci_mysql.so.4
        β”œβ”€β”€ libsoci_mysql.so.4 -> libsoci_mysql.so.4.1.0
        β”œβ”€β”€ libsoci_mysql.so.4.1.0
        β”œβ”€β”€ libsoci_odbc.so -> libsoci_odbc.so.4
        β”œβ”€β”€ libsoci_odbc.so.4 -> libsoci_odbc.so.4.1.0
        β”œβ”€β”€ libsoci_odbc.so.4.1.0
        β”œβ”€β”€ libsoci_postgresql.so -> libsoci_postgresql.so.4
        β”œβ”€β”€ libsoci_postgresql.so.4 -> libsoci_postgresql.so.4.1.0
        β”œβ”€β”€ libsoci_postgresql.so.4.1.0
        β”œβ”€β”€ libsoci_sqlite3.so -> libsoci_sqlite3.so.4
        β”œβ”€β”€ libsoci_sqlite3.so.4 -> libsoci_sqlite3.so.4.1.0
        └── libsoci_sqlite3.so.4.1.0

(not that I force-pushed my PR branch, so you’d have to do a hard reset to get the latest changes without merge conflicts)

Another problem is that /usr/lib64/libsoci_mysql.so is the library instead of being a link to the library, which have to be /usr/lib64/libsoci_mysql.so.4.1.0