Cmake unable to find PostgreSQL libraries When compiling SOCI

1k views Asked by At
  • OS: Windows 10
  • Compiler: Visual Studio 2019
  • SOCI Version: 4.0.2
  • PostgreSQL Version: 13
  • CMake VersionL 3.20.3

I'm not too familiar with CMake so bear with me if I'm doing something uninformed and incorrectly.

Steps:

  1. Download and execute postgresql-13.3-2-windows-x64.exe
  2. Download and execute pgadmin4-5.3-x64.exe
  3. Download and extract SOCI 4.0.2
  4. Create build directory in SOCI 4.0.2
  5. Call the following from cmd in the build directory:
cmake -G "Visual Studio 16 2019" .. -DWITH_BOOST=OFF -DWITH_POSTGRESQL=ON -DPOSTGRESQL_INCLUDE_DIR:STRING="c:/Program Files/PostgreSQL/13/include" -DPOSTGRESQL_LIBRARIES:STRING="c:/Program Files/PostgreSQL/13/lib" -DSOCI_STATIC=ON -DSOCI_SHARED=OFF

I got the following output

CMake Deprecation Warning at CMakeLists.txt:13 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.29.30037.0
-- The CXX compiler identification is MSVC 19.29.30037.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test SOCI_HAVE_VISIBILITY_SUPPORT
-- Performing Test SOCI_HAVE_VISIBILITY_SUPPORT - Failed
-- Looking for _M_AMD64
-- Looking for _M_AMD64 - found
-- Looking for _M_IX86
-- Looking for _M_IX86 - not found
-- Configuring SOCI:
-- SOCI_VERSION                             = 4.0.2
-- SOCI_ABI_VERSION                         = 4_0
-- SOCI_SHARED                              = OFF
-- SOCI_STATIC                              = ON
-- SOCI_TESTS                               = ON
-- SOCI_ASAN                                = OFF
-- SOCI_CXX11                               = OFF
-- LIB_SUFFIX                               = 64
-- Looking for SOCI dependencies:
-- Threads:
-- CMAKE_THREAD_LIBS_INIT                   =
-- Boost: disabled, since WITH_BOOST=OFF
-- MySQL:
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION - Failed
-- MySQL not found.
-- MySQL Embedded not found.
-- WARNING: MySQL libraries not found, some features will be disabled.
-- ODBC:
-- ODBC_INCLUDE_DIR                         =
-- ODBC_LIBRARIES                           = odbc32.lib
-- Oracle:
-- ORACLE_HOME=
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (ORACLE)
  does not match the name of the calling package (Oracle).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/modules/FindOracle.cmake:84 (find_package_handle_standard_args)
  cmake/dependencies/Oracle.cmake:3 (find_package)
  cmake/SociDependencies.cmake:79 (include)
  CMakeLists.txt:129 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- None of the supported Oracle versions (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:
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SQLITE3)
  does not match the name of the calling package (SQLite3).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/modules/FindSQLite3.cmake:57 (find_package_handle_standard_args)
  cmake/dependencies/SQLite3.cmake:3 (find_package)
  cmake/SociDependencies.cmake:79 (include)
  CMakeLists.txt:129 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- SQLite3 not found (SQLITE3_INCLUDE_DIR=SQLITE3_INCLUDE_DIR-NOTFOUND, SQLITE3_LIBRARY=SQLITE3_LIBRARY-NOTFOUND.
-- WARNING: SQLite3 libraries not found, some features will be disabled.
-- 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_4_0
-- SOCI_CORE_DEPS_LIBS                      =
-- SOCI_CORE_INCLUDE_DIRS                   = C:/Users/Hbagh/Downloads/soci-4.0.2/build C:/Users/Hbagh/Downloads/soci-4.0.2/include C:/Users/Hbagh/Downloads/soci-4.0.2/build/include C:/Users/Hbagh/Downloads/soci-4.0.2/include/private C:/Users/Hbagh/Downloads/soci-4.0.2/build/src/core
-- WITH_BOOST                               = OFF
-- COMPILE_DEFINITIONS                      = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF SOCI_LIB_PREFIX="soci_" SOCI_LIB_SUFFIX=".dll" SOCI_DEBUG_POSTFIX=""
--
-- Configuring SOCI backend libraries:
-- MySQL not found.
-- MySQL Embedded not found.
-- ORACLE_HOME=
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (ORACLE)
  does not match the name of the calling package (Oracle).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/modules/FindOracle.cmake:84 (find_package_handle_standard_args)
  src/backends/CMakeLists.txt:17 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- None of the supported Oracle versions (19;18;12;11;10) could be found, consider updating ORACLE_VERSIONS if the version you use is not among them.
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SQLITE3)
  does not match the name of the calling package (SQLite3).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/modules/FindSQLite3.cmake:57 (find_package_handle_standard_args)
  src/backends/CMakeLists.txt:17 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- SQLite3 not found (SQLITE3_INCLUDE_DIR=SQLITE3_INCLUDE_DIR-NOTFOUND, SQLITE3_LIBRARY=SQLITE3_LIBRARY-NOTFOUND.
-- Empty - SOCI backend skeleton for new backends development
-- SOCI_EMPTY                               = ON
-- SOCI_EMPTY_TARGET                        = soci_empty
-- SOCI_EMPTY_OUTPUT_NAME                   = soci_empty_4_0
-- SOCI_EMPTY_COMPILE_DEFINITIONS           = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF DBUG_OFF
-- SOCI_EMPTY_INCLUDE_DIRECTORIES           = C:/Users/Hbagh/Downloads/soci-4.0.2/build C:/Users/Hbagh/Downloads/soci-4.0.2/include C:/Users/Hbagh/Downloads/soci-4.0.2/build/include C:/Users/Hbagh/Downloads/soci-4.0.2/include/private C:/Users/Hbagh/Downloads/soci-4.0.2/include/private
-- ODBC - SOCI backend for ODBC
-- SOCI_ODBC                                = ON
-- SOCI_ODBC_TARGET                         = soci_odbc
-- SOCI_ODBC_OUTPUT_NAME                    = soci_odbc_4_0
-- SOCI_ODBC_COMPILE_DEFINITIONS            = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF DBUG_OFF
-- SOCI_ODBC_INCLUDE_DIRECTORIES            = C:/Users/Hbagh/Downloads/soci-4.0.2/build C:/Users/Hbagh/Downloads/soci-4.0.2/include C:/Users/Hbagh/Downloads/soci-4.0.2/build/include C:/Users/Hbagh/Downloads/soci-4.0.2/include/private C:/Users/Hbagh/Downloads/soci-4.0.2/include/private
--
-- Configuring SOCI tests:
-- SOCI_EMPTY_TEST_CONNSTR                  = dummy
-- SOCI_ODBC_TEST_ACCESS_CONNSTR            = FILEDSN=C:/Users/Hbagh/Downloads/soci-4.0.2/tests/odbc/test-access.dsn
-- SOCI_ODBC_TEST_MSSQL_CONNSTR             = FILEDSN=C:/Users/Hbagh/Downloads/soci-4.0.2/tests/odbc/test-mssql.dsn
-- SOCI_ODBC_TEST_MYSQL_CONNSTR             = FILEDSN=C:/Users/Hbagh/Downloads/soci-4.0.2/tests/odbc/test-mysql.dsn
-- SOCI_ODBC_TEST_POSTGRESQL_CONNSTR        = FILEDSN=C:/Users/Hbagh/Downloads/soci-4.0.2/tests/odbc/test-postgresql-win64.dsn
-- ODBC DB2 test disabled.
--
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    POSTGRESQL_LIBRARIES


-- Build files have been written to: C:/Users/Hbagh/Downloads/soci-4.0.2/build

The following stands out to me:

-- PostgreSQL:
-- WARNING: PostgreSQL libraries not found, some features will be disabled.
CMake Warning:
  Manually-specified variables were not used by the project:

    POSTGRESQL_LIBRARIES
1

There are 1 answers

0
Vadim Sukhorukov On

I faced with and fixed some issues. This command line worked for me:

cmake -G "Visual Studio 17" -DWITH_BOOST=OFF -DCMAKE_BUILD_TYPE=RELEASE -DSOCI_CXX11=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DWITH_DB2=OFF -DWITH_FIREBIRD=OFF -DWITH_MYSQL=OFF -DWITH_ODBC=OFF -DWITH_ORACLE=OFF -DWITH_POSTGRESQL=ON -DPOSTGRESQL_INCLUDE_DIR=D:/PostgreSQL/15/include -DPOSTGRESQL_LIBRARY=D:/PostgreSQL/15/lib/libpq.lib -DWITH_SQLITE3=OFF E:/dev/soci/soci-release-4.0

The list of issues is:

  1. "Program Files" - CMake incorrectly concatenates paths with spaces. I had to re-install Postrgres.
  2. Windows-style slashes - use Unix-style ones.
  3. -DPOSTGRESQL_LIBRARY=D:/PostgreSQL/15/lib/libpq.lib - this particular variable means a single lib file, not a path.