libpqxx: CMake MSVC x64 Windows compilation failed

Greetings. Trying to compile this library on windows. My project cmake:

cmake_minimum_required (VERSION 3.6)
set(CMAKE_CXX_STANDARD 23)

project(toolgun)

add_executable(toolgun main.cpp)

set(SKIP_BUILD_TEST ON)
set(BUILD_SHARED_LIBS ON)

set(PostgreSQL_ROOT "C:/Program Files/PostgreSQL/14/")

add_subdirectory(deps/libpqxx)

Here is how configuring went:

C:\Users\mails\Documents\C++\Toolgun\build>cmake .. -A x64
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.31.31105.0
-- The CXX compiler identification is MSVC 19.31.31105.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/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/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PostgreSQL: C:/Program Files/PostgreSQL/14/lib/libpq.lib (found version "14.2")
-- Looking for poll
-- Looking for poll - not found
-- Looking for PQencryptPasswordConn
-- Looking for PQencryptPasswordConn - not found
-- Looking for PQenterPipelineMode
-- Looking for PQenterPipelineMode - not found
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Generating config.h
-- Generating config.h - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/mails/Documents/C++/Toolgun/build

Here is how build went:

C:\Users\mails\Documents\C++\Toolgun\build>cmake --build . --config Debug
Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule C:/Users/mails/Documents/C++/Toolgun/deps/libpqxx/src/CMakeLists.txt
  array.cxx
  binarystring.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  blob.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  connection.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  cursor.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  encodings.cxx
  errorhandler.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  except.cxx
  field.cxx
  largeobject.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  notification.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  params.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  pipeline.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  result.cxx
  robusttransaction.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  row.cxx
  sql_cursor.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  strconv.cxx
  stream_from.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  stream_to.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  Generating Code...
  Compiling...
  subtransaction.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  time.cxx
  transaction.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  transaction_base.cxx
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,23): error C2672: 'binary_cast': no matching overloaded function foun
d [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/binarystring.hxx(220,1): error C7602: 'pqxx::binary_cast': the associated constraints are
not satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\src\transaction_base.cxx(217,23): error C2672: 'binary_cast': no matching overloaded function found [C:
\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\src\transaction_base.cxx(217,38): error C7602: 'pqxx::binary_cast': the associated constraints are not
satisfied [C:\Users\mails\Documents\C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
C:\Users\mails\Documents\C++\Toolgun\deps\libpqxx\include\pqxx/util.hxx(296): message : see declaration of 'pqxx::binary_cast' [C:\Users\mails\Documents\
C++\Toolgun\build\deps\libpqxx\src\pqxx.vcxproj]
  util.cxx
  version.cxx
  wait.cxx
  Generating Code...
  Building Custom Rule C:/Users/mails/Documents/C++/Toolgun/CMakeLists.txt
  main.cpp
C:\Users\mails\Documents\C++\Toolgun\main.cpp(2,10): fatal error C1083: Cannot open include file: 'pqxx/pqxx': No such file or directory [C:\Users\mails\
Documents\C++\Toolgun\build\toolgun.vcxproj]

Basically:

  • No ‘pqxx/pqxx’
  • binary_cast issue

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 46 (25 by maintainers)

Commits related to this issue

Most upvoted comments

Are you worried that SKIP_BUILD_TEST will be overwritten when you import other libraries with add_subdirectory()? Then don’t worry, CMake has different variable scopes for the child project imported by add_subdirectory() and for the parent project. Overwriting a variable in the child project does not effect the variable in the parent project.

Variables in the parent project can be rewritten if the PARENT_SCOPE option is specified in set(). However, this option is usually not used.

https://cmake.org/cmake/help/v3.23/command/set.html

I don’t see how I can copy pqxx.dll with CMake. Cmake builds it, so it knows everything about it

@GitSparTV You can use Cmake generator-expressions and add_custom_command().

By adding the following add_custom_command(), you should be able to copy the pqxx libraries to <OUTPUT_PATH> (replace with the destination directory) after the toolgun build is complete:

add_custom_command(TARGET toolgun POST_BUILD
	COMMAND ${CMAKE_COMMAND} -E $<TARGET_FILE:pqxx> <OUTPUT_PATH>
	VERBATIM
	COMMAND_EXPAND_LISTS
)

$<TARGET_FILE:pqxx> is a CMake generator-expression that is converted to the full path to the pqxx artifact.

It works if you replace using value_type = decltype(*std::begin(std::declval<CONTAINER>())); to using value_type = strip_t<decltype(*std::begin(std::declval<CONTAINER>()))>;

Because decltype(*std::begin(std::declval<CONTAINER>())); returns const char&, strip_t transforms back to char which works for msvc. But that’s certainly a bug because it’s const char& in gcc but it works

I do have automatic test builds on appveyor, so perhaps I can upgrade the compiler and/or the C++ version to reproduce the problem.

On Fri, Apr 8, 2022, 15:51 Spar @.***> wrote:

Tested on my machine, same behaviour

— Reply to this email directly, view it on GitHub https://github.com/jtv/libpqxx/issues/558#issuecomment-1092881849, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQYDE6Z6ULLEDHRUIPTYH3VEA2VFANCNFSM5S2INMLA . You are receiving this because you commented.Message ID: @.***>

Those warnings with c++latest are all outside of libpqxx — two in the compiler’s headers, and one in the application code. (Yes, main() should return int, not void.)

As for std::decay — it does a lot more than what I wanted. As the documentation says, I intend to replace pqxx::strip_t with std::remove_cvref.

Ah right. Problem is I don’t do much with CMake myself, so I’m entirely dependent on contributions there. Give me that half hour or so and I’ll be near a computer.

On Thu, Apr 7, 2022, 22:17 Spar @.***> wrote:

That’s what you have in BUILDING-cmake.md https://github.com/jtv/libpqxx/blob/master/BUILDING-cmake.md I did add target_link_libraries it didn’t fix the issue

— Reply to this email directly, view it on GitHub https://github.com/jtv/libpqxx/issues/558#issuecomment-1092162123, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQYDEYT77HNG4Q7VKQ5S6DVD47E5ANCNFSM5S2INMLA . You are receiving this because you commented.Message ID: @.***>