c++ - 无法构建cpprestsdk

标签 c++ cmake msys2 cpprest-sdk

当我尝试在 MSYS2 中构建 cpprestsdk ( https://github.com/Microsoft/cpprestsdk ) 时,我得到了一长串错误。这是我的环境:

  • Windows 10
  • 带有 i686-w64-mingw32 工具链的 MSYS2
  • 海湾合作委员会 6.3.0
  • 制作4.2.1
  • cmake 3.8.0

CMake

$ cmake -G "MSYS Makefiles" .. -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/dev/msys32/mingw32/bin/gcc.exe
-- Check for working C compiler: C:/dev/msys32/mingw32/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/dev/msys32/mingw32/bin/g++.exe
-- Check for working CXX compiler: C:/dev/msys32/mingw32/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Setting gcc options
-- websocketpp not found, using the embedded version
-- Boost version: 1.63.0
-- Found the following Boost libraries:
--   system
--   date_time
--   regex
-- Found OpenSSL: C:/dev/msys32/mingw32/lib/libssl.dll.a (found suitable version "1.0.2k", minimum required is "1.0.0")
-- Performing Test _SSL_LEAK_SUPPRESS_AVAILABLE
-- Performing Test _SSL_LEAK_SUPPRESS_AVAILABLE - Success
-- Found ZLIB: C:/dev/msys32/mingw32/lib/libz.dll.a (found version "1.2.11")
-- Added test library httpclient_test
-- Added test library httplistener_test
-- Added test library json_test
-- Added test library pplx_test
-- Added test library streams_test
-- Added test library uri_test
-- Added test library utils_test
-- Added test library websocketclient_test
-- Configuring done
-- Generating done
-- Build files have been written to: C:/cpprestsdk/Release/build.release

这里看起来一切正常

制作

$ make
Scanning dependencies of target cpprest
[  0%] Building CXX object src/CMakeFiles/cpprest.dir/http/client/http_client.cpp.obj
In file included from C:/cpprestsdk/Release/src/http/client/http_client.cpp:16:0:
C:/cpprestsdk/Release/src/pch/stdafx.h:43:0: error: "NOMINMAX" redefined [-Werror]
 #define NOMINMAX

In file included from C:/dev/msys32/mingw32/include/c++/6.3.0/i686-w64-mingw32/bits/c++config.h:507:0,
                 from C:/dev/msys32/mingw32/include/c++/6.3.0/string:38,
                 from C:/cpprestsdk/Release/include/cpprest/details/basic_types.h:16,
                 from C:/cpprestsdk/Release/src/pch/stdafx.h:23,
                 from C:/cpprestsdk/Release/src/http/client/http_client.cpp:16:
C:/dev/msys32/mingw32/include/c++/6.3.0/i686-w64-mingw32/bits/os_defines.h:45:0: note: this is the location of the previous definition
 #define NOMINMAX 1

In file included from C:/cpprestsdk/Release/src/pch/stdafx.h:104:0,
                 from C:/cpprestsdk/Release/src/http/client/http_client.cpp:16:
C:/cpprestsdk/Release/include/cpprest/interopstream.h:20:0: error: ignoring #pragma warning  [-Werror=unknown-pragmas]
 #pragma warning(push)

C:/cpprestsdk/Release/include/cpprest/interopstream.h:21:0: error: ignoring #pragma warning  [-Werror=unknown-pragmas]
 #pragma warning(disable : 4250)

In file included from C:/cpprestsdk/Release/src/pch/stdafx.h:104:0,
                 from C:/cpprestsdk/Release/src/http/client/http_client.cpp:16:
C:/cpprestsdk/Release/include/cpprest/interopstream.h:523:0: error: ignoring #pragma warning  [-Werror=unknown-pragmas]
 #pragma warning(pop)

In file included from C:/cpprestsdk/Release/src/pch/stdafx.h:143:0,
                 from C:/cpprestsdk/Release/src/http/client/http_client.cpp:16:
C:/cpprestsdk/Release/include/cpprest/details/http_server_httpsys.h:19:0: error: ignoring #pragma warning  [-Werror=unknown-pragmas]
 #pragma warning(push)

C:/cpprestsdk/Release/include/cpprest/details/http_server_httpsys.h:20:0: error: ignoring #pragma warning  [-Werror=unknown-pragmas]
 #pragma warning(disable : 6386)

In file included from C:/cpprestsdk/Release/src/pch/stdafx.h:143:0,
                 from C:/cpprestsdk/Release/src/http/client/http_client.cpp:16:
C:/cpprestsdk/Release/include/cpprest/details/http_server_httpsys.h:22:0: error: ignoring #pragma warning  [-Werror=unknown-pragmas]
 #pragma warning(pop)

In file included from C:/cpprestsdk/Release/include/pplx/pplxwin.h:19:0,
                 from C:/cpprestsdk/Release/include/pplx/pplx.h:43,
                 from C:/cpprestsdk/Release/include/pplx/pplxtasks.h:42,
                 from C:/cpprestsdk/Release/src/pch/stdafx.h:97,
                 from C:/cpprestsdk/Release/src/http/client/http_client.cpp:16:
C:/cpprestsdk/Release/include/pplx/pplxinterface.h:52:29: error: 'novtable' attribute directive ignored [-Werror=attributes]
 struct __declspec(novtable) scheduler_interface
                             ^~~~~~~~~~~~~~~~~~~
In file included from C:/cpprestsdk/Release/include/pplx/pplx.h:43:0,
                 from C:/cpprestsdk/Release/include/pplx/pplxtasks.h:42,
                 from C:/cpprestsdk/Release/src/pch/stdafx.h:97,
                 from C:/cpprestsdk/Release/src/http/client/http_client.cpp:16:
C:/cpprestsdk/Release/include/pplx/pplxwin.h:175:14: error: extra qualification 'pplx::details::recursive_lock_impl::' on member 'lock' [-fpermissive]
         void recursive_lock_impl::lock()
              ^~~~~~~~~~~~~~~~~~~
C:/cpprestsdk/Release/include/pplx/pplxwin.h:191:14: error: extra qualification 'pplx::details::recursive_lock_impl::' on member 'unlock' [-fpermissive]
         void recursive_lock_impl::unlock()
              ^~~~~~~~~~~~~~~~~~~
C:/cpprestsdk/Release/include/pplx/pplxwin.h: In constructor 'pplx::details::recursive_lock_impl::recursive_lock_impl()':
C:/cpprestsdk/Release/include/pplx/pplxwin.h:208:23: error: 'pplx::details::recursive_lock_impl::_M_owner' will be initialized after [-Werror=reorder]
         volatile long _M_owner;
...

输出很长。这些只是第一个错误。 这里发生了什么?

最佳答案

cpprestsdk的开发者官方立场如下:

https://github.com/Microsoft/cpprestsdk/issues/202

We don't officially support mingw on Windows; if you're able to get this to work please post back with your results.

现在 make 命令的输出包含 264 个错误,其中大部分是:

  • 错误:“_ASSERTE”未在此范围内声明
  • 错误:宽松的 throw 说明符 ...
  • 覆盖“virtual const char* std::exception::what() const noexcept”
  • 没有依赖于模板参数的 ... 参数,因此 ... 的声明必须可用 [-fpermissive]
  • 静态断言失败:不支持从流中提取类型
  • ...不是一个类型
  • 在...之前需要“typename”,因为...是一个从属范围
  • 预期';'之前……
  • '*' 标记前的预期主表达式
  • ...

我想修复它们需要深入编辑代码。

关于c++ - 无法构建cpprestsdk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43527341/

相关文章:

windows - 在 Windows 上找不到 valac 命令

C++ 类和变量

c++ - 使用 std::tr1::function(或 boost::function)创建多播事件

c++ - 在 TravisCI 下为 cmake 更改 C++ 编译器

c++ - "The C Compiler [...] is not able to compile a simple test program"使用 CMake 和 Android NDK

ffmpeg mingw 编译 8192 字符限制 - 重新访问

windows - msys/git 和 git-for-windows/mingw-w64-x86_64-git 有什么区别?

c++ - QtCreator 4.1.0 不显示 MainWindow 表单编辑器的 webengineview(QT 5.7)

c++ - 在 C++ 上发送/接收 TCP/IP

cmake - 如何使用 CMake 为 LLVM 生成 64 位 Visual Studio 项目?