Search code examples
c++cmakevcpkgetcd3

Error in pplx when runing project with etcd-client-v3 library installed with vcpkg


I have a project where I want to use etcd-cpp-apiv3 library(https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3), so I installed with vcpkg. But when I run it, fails.

I installed it with vcpkg: 'vcpkg install etcd-cpp-apiv3:x64-windows' and included it with these cmake commands:

set(VCPKG_ROOT "C:/vcpkg")
set(VCPKG_TARGET_TRIPLET "x64-windows")
set(CMAKE_TOOLCHAIN_FILE "C:/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_PREFIX_PATH "${VCPKG_ROOT}/installed/x64-windows")

include_directories(${CMAKE_PREFIX_PATH}/include)
find_package(etcd-cpp-api CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE etcd-cpp-api)

It recognizes the include statement: #include <etcd/Client.hpp> But when I run the project I get so many errors on pplx header files located in vcpkg installation folder: C:/vcpkg/installed/x64-windows/include/pplx Examples of these errors

C:/vcpkg/installed/x64-windows/include/pplx/pplxtasks.h:2877:21: error: '_ASSERTE' was not declared in this scopeIn main

C:/vcpkg/installed/x64-windows/include/pplx/pplxtasks.h:222:104: note: in definition of macro 'PPLX_CAPTURE_CALLSTACK' 222 | #define PPLX_CAPTURE_CALLSTACK() ::pplx::details::_TaskCreationCallstack::_CaptureSingleFrameCallstack(_ReturnAddress())

C:/vcpkg/installed/x64-windows/include/pplx/pplxtasks.h: In instantiation of 'pplx::details::_Task_completion_event_impl<_ResultType>::~_Task_completion_event_impl() [with _ResultType = unsigned char]':

Apparently the library uses pplx

I have tried to add manually pplx library with target_include_libraries but I dont know if that makes any sense. I have also tried to remove output cmake folder, reinstall all vcpkg, make sure the the vcpkg paths and environtment variables are set up correctly, make sure that I was dowloading x64 bits libraries etc but none worked.

Im using windows 64 bit, with clion.

If someone could help me or give a clue about what is going on, I would be very pleased


Solution

  • I found the error.

    Etcd-clientv3 library uses cpprest library which only supports Microsoft's C++ compiler, MSVC. As I was using Clion's default compiler, Mingw, there were lot of errors when compiling cpprest.

    The solution was to change clion's compiler to MSVC