microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
8.01k stars 1.66k forks source link

Build error with Visual Studio 2019 #1227

Open JackBoosY opened 5 years ago

JackBoosY commented 5 years ago

Hi developers. Recently I tried to install cpprestsdk using vcpkg, and I got the error: c1xx: error C2338: two-phase name lookup is not supported for C++/CLI, C++/CX, or OpenMP; use /Zc:twoPhase-

And then when I add compile option /Zc:twoPhase- to CMakeLists.txt, I got error: 4>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\include\ppltasks.h(5920,13): error C3861: '_CheckValidStateForResultsCall': identifier not found

Can anyone help me?

Thanks.

Related: #7540.

metathinker commented 5 years ago

I have this problem too - I can reproduce it with vcpkg at commit 2b78cac3, which currently pulls in cpprestsdk v2.10.14.

It only reproduces in the vcpkg "uwp" triple flavor (universal Windows apps), and not the "windows" flavor (classic desktop Windows apps). On "uwp", it reproduces on both "x86" and "x64".

It reproduces with Visual Studio 2019 version 16.2.3 incorporating MSVC compiler version 19.22.27905 (full compiler version info below from cl /Bv).

Command output:

[command prompt opened with D:\vcpkg\vcpkg.exe env ]
D:\vcpkg> where cl
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\Hostx64\x86\cl.exe
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\Hostx64\x64\cl.exe

D:\vcpkg> cl.exe /Bv
Microsoft (R) C/C++ Optimizing Compiler Version 19.22.27905 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

Compiler Passes:
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x86\cl.exe:        Version 19.22.27905.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x86\c1.dll:        Version 19.22.27905.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x86\c1xx.dll:      Version 19.22.27905.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x86\c2.dll:        Version 19.22.27905.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x86\link.exe:      Version 14.22.27905.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x86\mspdb140.dll:  Version 14.22.27905.0
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x86\1033\clui.dll: Version 19.22.27905.0

cl : Command line error D8003 : missing source filename

D:\vcpkg> D:\vcpkg\vcpkg.exe install cpprestsdk[core]:x86-uwp
The following packages will be built and installed:
    cpprestsdk[core]:x86-uwp
Starting package 1/1: cpprestsdk:x86-uwp
Building package cpprestsdk[core]:x86-uwp...
-- Using cached D:/vcpkg/downloads/Microsoft-cpprestsdk-v2.10.14.tar.gz
-- Using source at D:/vcpkg/buildtrees/cpprestsdk/src/v2.10.14-101423beaf
-- Configuring x86-uwp
-- Building x86-uwp-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:136 (message):
    Command failed: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe" --build . --config Debug --target install -- /p:VCPkgLocalAppDataDisabled=true /p:UseIntelMKL=No /m
    Working Directory: D:/vcpkg/buildtrees/cpprestsdk/x86-uwp-dbg
    See logs for more information:
      D:\vcpkg\buildtrees\cpprestsdk\install-x86-uwp-dbg-out.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_build_cmake.cmake:96 (vcpkg_execute_build_process)
  scripts/cmake/vcpkg_install_cmake.cmake:24 (vcpkg_build_cmake)
  ports/cpprestsdk/portfile.cmake:50 (vcpkg_install_cmake)
  scripts/ports.cmake:85 (include)

Error: Building package cpprestsdk:x86-uwp failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: cpprestsdk:x86-uwp
  Vcpkg version: 2019.08.27-nohash-external

Additionally, attach any relevant sections from the log files above.

The file mentioned is: install-x86-uwp-dbg-out.log

And the relevant section of that file is the same error message you reported above, @JackBoosY:

    stdafx.cpp
    c1xx: error C2338: two-phase name lookup is not supported for C++/CLI, C++/CX, or OpenMP; use /Zc:twoPhase-
    c1xx: fatal error C1903: unable to recover from previous error(s); stopping compilation
4>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(320,5): error MSB6006: "CL.exe" exited with code 2. [D:\vcpkg\buildtrees\cpprestsdk\x86-uwp-dbg\src\cpprest.vcxproj]
debalin commented 5 years ago

I am facing the same issue with vcpkg, both cpprestsdk:x86-uwp and cpprestsdk:x64-uwp and VS 2019 16.3.0.

C:\Code\vcpkg [master ≡]> .\vcpkg.exe install cpprestsdk:x86-uwp
The following packages will be built and installed:
    cpprestsdk[compression,core,default-features,websockets]:x86-uwp
Starting package 1/1: cpprestsdk:x86-uwp
Building package cpprestsdk[compression,core,default-features,websockets]:x86-uwp...
-- Downloading https://github.com/Microsoft/cpprestsdk/archive/v2.10.14.tar.gz...
-- Using source at C:/Code/vcpkg/buildtrees/cpprestsdk/src/v2.10.14-101423beaf
-- Configuring x86-uwp
-- Building x86-uwp-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:136 (message):
    Command failed: C:/Code/vcpkg/downloads/tools/cmake-3.14.0-windows/cmake-3.14.0-win32-x86/bin/cmake.exe --build . --config Debug --target install -- /p:VCPkgLocalAppDataDisabled=true /p:UseIntelMKL=No /m
    Working Directory: C:/Code/vcpkg/buildtrees/cpprestsdk/x86-uwp-dbg
    See logs for more information:
      C:\Code\vcpkg\buildtrees\cpprestsdk\install-x86-uwp-dbg-out.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_build_cmake.cmake:96 (vcpkg_execute_build_process)
  scripts/cmake/vcpkg_install_cmake.cmake:24 (vcpkg_build_cmake)
  ports/cpprestsdk/portfile.cmake:50 (vcpkg_install_cmake)
  scripts/ports.cmake:94 (include)

Error: Building package cpprestsdk:x86-uwp failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: cpprestsdk:x86-uwp
  Vcpkg version: 2019.09.12-nohash

Additionally, attach any relevant sections from the log files above.

The log file gives this:

c1xx: error C2338: two-phase name lookup is not supported for C++/CLI, C++/CX, or OpenMP; use /Zc:twoPhase-

I added the compiler option /Zc:twoPhase-, and now I get the exact same error as @JackBoosY mentioned.

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\ppltasks.h(5920,13): error C3861: '_CheckValidStateForResultsCall': identifier not found (compiling source file C:\Code\vcpkg\buildtrees\cpprestsdk\src\v2.10.14-101423beaf\Release\src\streams\fileio_winrt.cpp)

Did anybody else here find a workaround to this?

gazzyt commented 4 years ago

I ran into this while using vcpkg. It seems to be a problem with cpprestsdk v2.10.14 which vcpkg pulls in. Changing the portfile to pull in the latest commit allows it to build and install uwp builds fine. My modified lines in portfile.cmake were:

    REF 96e7d20e398b629de2935f9ac32cfa2780cd0b0b
    SHA512 9f44b8be102489b88e088a654b6a59cd883c294d2b95cfe9e13a90de5300efabe25736bbb371945bd87329b02d5fe2c2cc9ee9d334f79c89768d2a26a8ba9ed5

I guess we are just waiting for a new release of cpprestsdk to be tagged.