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.02k stars 1.65k forks source link

Compilation with newest cpp/gcc #1348

Open LeeRuns opened 4 years ago

LeeRuns commented 4 years ago

Don't see a reason why this cannot be fixed. Right now it is blowing up my compilation. Do not want to use ubuntu lib because that will mean that i have to count on two seperate companies to keep versions straight and compatible. Instead i just want to compile in my larger project.

image

c72578 commented 4 years ago

all warnings being treated as errors ... Please have a look here: https://github.com/microsoft/cpprestsdk/issues/1343#issuecomment-590004873

LeeRuns commented 4 years ago

Does not fix the problem, is really just a hack right? I don't want to change the way all of my other projects build by editing something so fundamental in my top lvl cmake file.

is there something i am missing?

garethsb commented 4 years ago

C++20 was only finalised this month, and implicit capture of *this by reference with = is only deprecated, not removed, so it's hardly surprising that this issue exists in this code base and many others.

It should be resolved by adding explicit capture of this pointer and using this->. I'm sure a pull request would be welcome if you're impatient to operate with C++20.

LeeRuns commented 4 years ago

Cpp 20 release plans have been well published for a while. Long enough that the compiler code has already been updated to handle, so I would not say that it is unreasonable to expect the code base to be updated to latest stdlib...but I'd like to put that aside and discuss a solution for this situation.

I went to compile seperately

All that aside I am just looking for a way to compile this inside of a larger project, and it's not working. When i use the ubuntu lib install i get one set of compiler errors, then when i do (my preferred method) cmake compilation, I get a different set of errors. However just running gcc 9.1 which release almost a year ago it is wanting to compile...

Step 37/47 : RUN cmake -Bbuild -H. -DBUILD_TESTING=OFF
 ---> Running in 5d39c48092cb
-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- 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 - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Looking for include file xlocale.h
-- Looking for include file xlocale.h - not found
-- Setting gcc options
-- Found websocketpp version 0.7.0 on system
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   random
--   system
--   thread
--   filesystem
--   chrono
--   atomic
--   date_time
--   regex
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for one of the modules 'openssl'
-- Performing Test _SSL_LEAK_SUPPRESS_AVAILABLE
-- Performing Test _SSL_LEAK_SUPPRESS_AVAILABLE - Failed
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (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 websocketsclient_test
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_TESTING

-- Build files have been written to: /app/opt/SimComposer/extern/cpprestsdk/build
Removing intermediate container 5d39c48092cb
 ---> 75b01e721791
Step 38/47 : RUN sudo cmake --build build/ --target install
 ---> Running in f3a28d8acc8f
Scanning dependencies of target cpprest
[  1%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/client/http_client.cpp.o
[  1%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/client/http_client_msg.cpp.o
[  2%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/common/http_compression.cpp.o
[  3%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/common/http_helpers.cpp.o
[  3%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/common/http_msg.cpp.o
[  4%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/listener/http_listener.cpp.o
[  5%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/listener/http_listener_msg.cpp.o
[  5%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/listener/http_server_api.cpp.o
[  6%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/oauth/oauth1.cpp.o
[  6%] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/oauth/oauth2.cpp.o
[  7%] Building CXX object Release/src/CMakeFiles/cpprest.dir/json/json.cpp.o
[  8%] Building CXX object Release/src/CMakeFiles/cpprest.dir/json/json_parsing.cpp.o
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp: In instantiation of 'std::unique_ptr<web::json::details::_Value> web::json::details::JSON_Parser<CharType>::_ParseValue(web::json::details::JSON_Parser<CharType>::Token&) [with CharType = char]':
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:131:33:   required from 'web::json::value web::json::details::JSON_Parser<CharType>::ParseValue(web::json::details::JSON_Parser<CharType>::Token&) [with CharType = char]'
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1183:10:   required from 'web::json::value _parse_string(const std::__cxx11::basic_string<_CharT>&) [with CharType = char]'
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1220:98:   required from here
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1077:35: error: redundant move in return statement [-Werror=redundant-move]
 1077 |             return std::move(value);
      |                                   ^
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1077:35: note: remove 'std::move' call
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1089:35: error: redundant move in return statement [-Werror=redundant-move]
 1089 |             return std::move(value);
      |                                   ^
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1089:35: note: remove 'std::move' call
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1096:35: error: redundant move in return statement [-Werror=redundant-move]
 1096 |             return std::move(value);
      |                                   ^
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1096:35: note: remove 'std::move' call
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1103:35: error: redundant move in return statement [-Werror=redundant-move]
 1103 |             return std::move(value);
      |                                   ^
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1103:35: note: remove 'std::move' call
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp: In instantiation of 'std::unique_ptr<web::json::details::_Value> web::json::details::JSON_Parser<CharType>::_ParseArray(web::json::details::JSON_Parser<CharType>::Token&) [with CharType = char]':
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1069:20:   required from 'std::unique_ptr<web::json::details::_Value> web::json::details::JSON_Parser<CharType>::_ParseValue(web::json::details::JSON_Parser<CharType>::Token&) [with CharType = char]'
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:131:33:   required from 'web::json::value web::json::details::JSON_Parser<CharType>::ParseValue(web::json::details::JSON_Parser<CharType>::Token&) [with CharType = char]'
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1183:10:   required from 'web::json::value _parse_string(const std::__cxx11::basic_string<_CharT>&) [with CharType = char]'
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1220:98:   required from here
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1043:44: error: redundant move in return statement [-Werror=redundant-move]
 1043 |                     return std::move(result);
      |                                            ^
/app/opt/MySuperProject/extern/cpprestsdk/Release/src/json/json_parsing.cpp:1043:44: note: remove 'std::move' call
cc1plus: all warnings being treated as errors
Release/src/CMakeFiles/cpprest.dir/build.make:205: recipe for target 'Release/src/CMakeFiles/cpprest.dir/json/json_parsing.cpp.o' failed
make[2]: *** [Release/src/CMakeFiles/cpprest.dir/json/json_parsing.cpp.o] Error 1
CMakeFiles/Makefile2:114: recipe for target 'Release/src/CMakeFiles/cpprest.dir/all' failed
Makefile:140: recipe for target 'all' failed
make[1]: *** [Release/src/CMakeFiles/cpprest.dir/all] Error 2
make: *** [all] Error 2
ERROR: Service 'mysuperproject' failed to build: The command '/bin/sh -c sudo cmake --build build/ --target install' returned a non-zero code: 2

I all i did was run this inside of my docker ubuntu file. I know you guys are careful, so please tell me what am i doing wrong.

c72578 commented 4 years ago

Are you sure, you have turned off WERROR? There is still cc1plus: all warnings being treated as errors in the output. Additional remark: -DBUILD_TESTING=OFF-> -DBUILD_TESTS=OFF See: https://github.com/microsoft/cpprestsdk/blob/cdae258bfb22f948c7b768b4dc56f5f4a2d9b2ce/Release/CMakeLists.txt#L36 So, the cmake command should be something like: cmake .. -DCMAKE_BUILD_TYPE=Release -DWERROR=OFF -DBUILD_TESTS=OFF

LeeRuns commented 4 years ago

I have come up with several solutions based on this feedback and am working to try each

method 1: develop compilation outside of current cmake build

method 2: develop compilation outside of current cmake build

method 3: restructure the cmake file so that it can be run with cpp20 by turning off flag warning as error

method 4: restructure that compiles with cpp 20

I prefer method 4, but putting together some kind of directions on how to incorporate your cmake build into a larger build would really be great. Assuming that this is being used as a 3rd party library.