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
- Strip `const` and `&` from `value_type`. See #558. MSVC in C++20 or C++23 mode complains without this. — committed to jtv/libpqxx by jtv 2 years ago
- Strip `const` and `&` from `value_type`. (#559) See #558. MSVC in C++20 or C++23 mode complains without this. — committed to jtv/libpqxx by jtv 2 years ago
- Update `BUILDING-cmake.md`. See #558. I'm not a CMake expert, but trying to follow along with @GitSparTV and @tt4g and update the instructions. — committed to jtv/libpqxx by jtv 2 years ago
Are you worried that
SKIP_BUILD_TESTwill be overwritten when you import other libraries withadd_subdirectory()? Then don’t worry, CMake has different variable scopes for the child project imported byadd_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_SCOPEoption is specified inset(). However, this option is usually not used.https://cmake.org/cmake/help/v3.23/command/set.html
@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 thetoolgunbuild is complete:$<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>()));tousing value_type = strip_t<decltype(*std::begin(std::declval<CONTAINER>()))>;Because
decltype(*std::begin(std::declval<CONTAINER>()));returnsconst char&, strip_t transforms back tocharwhich works for msvc. But that’s certainly a bug because it’sconst char&in gcc but it worksI 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:
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 returnint, notvoid.)As for
std::decay— it does a lot more than what I wanted. As the documentation says, I intend to replacepqxx::strip_twithstd::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: