Search code examples
c++mysqlboostcmakesoci

How do I build the SOCI library without errors?


I am having difficulties building the SOCI library.

Relevant software:

  • Boost ver 1.73.0
  • CMake ver 3.16
  • MSVC compiler ver 19.26.28805.0
  • MySQL ver 5.7
  • SOCI ver 4.0.0

Relevant paths:

  • Path to Boost is E:\cpp\Lib\boost\boost_1_73_0.
  • Path to CMake is E:\Apps\CMake\share\cmake-3.16.
  • Path to MySQL server is C:\Program Files\MySQL\MySQL Server 5.7\.
  • Path to MSVC is C:\Apps\32\Microsoft\Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\Hostx64\x64.

Command to build SOCI is cmake -DCMAKE_BUILD_TYPE=Debut -DSOCI_CXX11=ON -DSOCI_SHARED=ON -DWITH_BOOST=ON -DWITH_MYSQL=ON ..

Here is the modified Boost.cmake file, found at %SOCI%\cmake\dependencies\. Comments beginning ## explain changes.

## commented
#set(Boost_FIND_QUIETLY TRUE)

set(Boost_USE_MULTITHREADED ON)
## commented
#find_package(Boost 1.33.1 COMPONENTS date_time)

## BEGIN inserted
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "E:/cpp/Lib/boost/boost_1_73_0")
message(STATUS "<< set CMAKE_INCLUDE_PATH >> " ${CMAKE_INCLUDE_PATH})

set(BOOST_ROOT E:/cpp/Lib/boost/boost_1_73_0)
message(STATUS "<< set BOOST_ROOT >> " ${BOOST_ROOT})

message(STATUS "<< FIND_PACKAGE >>")
FIND_PACKAGE(Boost)

message(STATUS "<< FIND_PACKAGE COMPONENTS >>")
FIND_PACKAGE(Boost COMPONENTS date_time)

message(STATUS "<< Boost_FOUND >> " ${Boost_FOUND})

message(STATUS "<< Boost_DATE_TIME_FOUND >> " ${Boost_DATE_TIME_FOUND})
## END inserted

## commented
#if (NOT Boost_DATE_TIME_FOUND)
#  find_package(Boost 1.33.1)
#endif()

set(Boost_RELEASE_VERSION
  "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")

boost_external_report(Boost RELEASE_VERSION INCLUDE_DIR LIBRARIES)

Here is the relevant output. Full output available here.

-- Boost:
-- << set CMAKE_INCLUDE_PATH >> E:/cpp/Lib/boost/boost_1_73_0
-- << set BOOST_ROOT >> E:/cpp/Lib/boost/boost_1_73_0
-- << FIND_PACKAGE >>
-- << FIND_PACKAGE COMPONENTS >>
CMake Warning at E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1161 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1283 (_Boost_COMPONENT_DEPENDENCIES)
  E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1921 (_Boost_MISSING_DEPENDENCIES)
  cmake/dependencies/Boost.cmake:18 (FIND_PACKAGE)
  cmake/SociDependencies.cmake:79 (include)
  CMakeLists.txt:83 (include)


-- Could NOT find Boost (missing: date_time) (found version "1.73.0")
-- << Boost_FOUND >> FALSE
-- << Boost_DATE_TIME_FOUND >> 0
-- WARNING: Boost libraries not found, some features will be disabled.

Executing msbuild.exe SOCI.sln produces output available here.

Can anyone tell me why SOCI will not build correctly? Why is it not finding the date_time component when it is most certainly there?


Solution

  • Turns out, most of the errors I was getting was from the included unit tests. Why? I do not know. However, if I ignore the errors and move on, everything seems to work fine.