0

When I try to build cpprestsdk (https://github.com/Microsoft/cpprestsdk) in MSYS2 I get a very long list of errors. Here my enviroment:

  • Windows 10
  • MSYS2 with i686-w64-mingw32 toolchain
  • gcc 6.3.0
  • make 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

Here seems all ok.

Make

$ 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;
...

The output is very long. These are only the first errors. What's happening here?

Mark
  • 4,338
  • 7
  • 58
  • 120

3 Answers3

4

The official position of the developers of cpprestsdk is the following:

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.

Right now the output of the make command contains 264 errors, most of them are:

  • error: '_ASSERTE' was not declared in this scope
  • error: looser throw specifier for ...
  • overriding 'virtual const char* std::exception::what() const noexcept'
  • there are no arguments to ... that depend on a template parameter, so a declaration of ... must be available [-fpermissive]
  • static assertion failed: type is not supported for extraction from a stream
  • ... is not a type
  • need 'typename' before ... because ... is a dependent scope
  • expected ';' before ...
  • expected primary-expression before '*' token
  • ...

I guess fix them will require to deeply edit the code.

Mark
  • 4,338
  • 7
  • 58
  • 120
1

All these errors seem to be warnings treated as errors. And almost all of of them are rather harmless (except for reorder). You probably have -Werror "warnings as errors" option turned on somewhere is CMAKE files.

user7860670
  • 35,849
  • 4
  • 58
  • 84
  • Perhaps this line? `set(WERROR ON CACHE BOOL "Treat Warnings as Errors.")` is here: https://github.com/Microsoft/cpprestsdk/blob/master/Release/CMakeLists.txt – Mark Apr 20 '17 at 18:52
  • Looks like that. – user7860670 Apr 20 '17 at 18:54
  • Am I supposed to change it commenting the whole line? it's in the official repository! – Mark Apr 20 '17 at 18:56
  • Just get rid of that line. I don't even remember the last time I managed to build something from "official repository" without messing with build scripts quite a bit. And you probably will still need to make a few fixes in code here and there to make it compile properly after all these forced errors go away. – user7860670 Apr 20 '17 at 19:00
  • You're right. Now those errors are warnings. Still there are other errors, i.e. `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()`. I'm not able to fix issues like that... I should open another question to better understand what's going on? – Mark Apr 20 '17 at 19:10
  • I don't think enabling `fpermissive` to downgrade also these errors to warnings is a good choice... – Mark Apr 20 '17 at 19:10
  • This is just a typo. Just remove a `recursive_lock_impl::` from method declaration. I think it is a legacy from old VS versions that silently allowed to put class name prefix in class member declaration inside of a class. – user7860670 Apr 20 '17 at 19:13
  • I'm going to open an issue on github to ask if their code is ready to be compiled under minGW. In the output there are 264 errors... - **EDIT:** useless: https://github.com/Microsoft/cpprestsdk/issues/202 – Mark Apr 20 '17 at 19:25
  • @Mark: Shouldn't your last comment be a **separate answer** instead? Diagnostic "Isn't supported" from the developers is much different from "you may try this or that". – Tsyvarev Apr 20 '17 at 19:38
0

before buiilding the cpprestsdk install websocketpp using vcpkg vcpkg install --triplet x64-windows zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli

Full restcppsdk build guide & source code https://sageai.blogspot.com/2020/12/how-to-build-cpprestsdk-using-vcpkg-in.html