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

CentOS 7 build failure #682

Open maaltan opened 6 years ago

maaltan commented 6 years ago

I am having problems building this library in centOS 7. After installing/updating several libraries cmake was looking for, i am still looking at several errors involving "unused parameter 'other'"

`In file included from /home/asdf/otherdev/cpprestsdk/Release/src/pch/stdafx.h:108:0, from /home/asdf/otherdev/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h:32:13: error: unused parameter ‘other’ [-Werror=unused-parameter] uri_components(const uri_components &other) = default; ^ In file included from /home/asdf/otherdev/cpprestsdk/Release/src/pch/stdafx.h:108:0, from /home/asdf/otherdev/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h: In copy constructor ‘web::uri::uri(const web::uri&)’: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h:212:9: note: synthesized method ‘web::details::uri_components::uri_components(const web::details::uri_components&)’ first required here uri(const uri &other) = default; ^ /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h: At global scope: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h:212:9: error: unused parameter ‘other’ [-Werror=unused-parameter] In file included from /home/asdf/otherdev/cpprestsdk/Release/src/pch/stdafx.h:112:0, from /home/asdf/otherdev/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/details/web_utilities.h: In constructor ‘web::web_proxy::web_proxy(web::uri)’: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/details/web_utilities.h:162:73: note: synthesized method ‘web::uri::uri(const web::uri&)’ first required here web_proxy( uri address ) : m_address(address), m_mode(userprovided) {} ^ In file included from /home/asdf/otherdev/cpprestsdk/Release/src/pch/stdafx.h:108:0, from /home/asdf/otherdev/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h: At global scope: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h:28:16: error: unused parameter ‘other’ [-Werror=unused-parameter] struct uri_components ^ /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h: In member function ‘web::uri& web::uri::operator=(const web::uri&)’: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h:118:11: note: synthesized method ‘web::details::uri_components& web::details::uri_components::operator=(const web::details::uri_components&)’ first required here class uri ^ /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h: At global scope: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/base_uri.h:118:11: error: unused parameter ‘other’ [-Werror=unused-parameter] In file included from /home/asdf/otherdev/cpprestsdk/Release/src/pch/stdafx.h:116:0, from /home/asdf/otherdev/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/http_msg.h: In member function ‘void web::http::details::_http_request::_set_base_uri(const web::uri&)’: /home/asdf/otherdev/cpprestsdk/Release/include/cpprest/http_msg.h:799:64: note: synthesized method ‘web::uri& web::uri::operator=(const web::uri&)’ first required here void _set_base_uri(const http::uri &base_uri) { m_base_uri = base_uri; } ^ cc1plus: all warnings being treated as errors make[2]: [src/CMakeFiles/cpprest.dir/http/client/http_client.cpp.o] Error 1 make[1]: [src/CMakeFiles/cpprest.dir/all] Error 2 make: *** [all] Error 2

`

here is the output of cmake: `-- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /bin/gcc -- Check for working C compiler: /bin/gcc -- 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: /bin/c++ -- Check for working CXX compiler: /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 - found -- Setting gcc options -- websocketpp not found, using the embedded version -- Boost version: 1.53.0 -- Found the following Boost libraries: -- random -- system -- thread -- filesystem -- chrono -- atomic -- date_time -- regex -- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (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: /usr/lib64/libz.so (found version "1.2.7") -- 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 -- Build files have been written to: /home/asdf/otherdev/cpprestsdk/Release/build.debug

`

ras0219-msft commented 6 years ago

This can be worked around with -DWERROR=OFF passed to the initial cmake configure. Thanks for reporting!

PBRCW commented 6 years ago

"unused parameter" messages are indeed not an error but a warning in many compilers (except you configure it otherwise). This can be safely ignored and the error being switched off for non-library-implementors. Nevertheless the Casablanca team could've done better, there's a standard compliant way to disable this warning/error per call: Simply leave it unnamed. Plus in C++14 we have the attribute [[maybe-unused]], so they should've made it so that those warnings are not triggered at all. There's no big magic behind that, this C++ feature is no breaking news and pros should know how to handle that appropriately!

maaltan commented 6 years ago

Thanks for the help. I have new errors now these seem "real". One thing i noticed when trying to bypass the issues above is the required boost version for the 2.9.X branches require a newer version of boost that CentOS can provide from standard repositories (1.54 i believe. CentOS 7 provides 1.53)

[ 51%] Building CXX object tests/functional/http/listener/CMakeFiles/httplistener_test.dir/listener_construction_tests.cpp.o /home/asdf/otherdev/cpprestsdk/Release/tests/functional/http/listener/listener_construction_tests.cpp: In lambda function: /home/asdf/otherdev/cpprestsdk/Release/tests/functional/http/listener/listener_construction_tests.cpp:535:17: error: ‘class boost::asio::ssl::context’ has no member named ‘use_certificate_chain’ ctx.use_certificate_chain(cert); ^ /home/asdf/otherdev/cpprestsdk/Release/tests/functional/http/listener/listener_construction_tests.cpp:536:17: error: ‘class boost::asio::ssl::context’ has no member named ‘use_private_key’ ctx.use_private_key(key, boost::asio::ssl::context::pem); ^ /home/asdf/otherdev/cpprestsdk/Release/tests/functional/http/listener/listener_construction_tests.cpp: In lambda function: /home/asdf/otherdev/cpprestsdk/Release/tests/functional/http/listener/listener_construction_tests.cpp:563:17: error: ‘class boost::asio::ssl::context’ has no member named ‘add_certificate_authority’

PBRCW commented 6 years ago

Huh? boost V1.53 stems from February 2013 and is 5 years old now, current version is V1.66. Do they really stay with such an old version in a current OS release? I guess Casablanca does not cater for such old versions, updating boost will presumably be unavoidable for you.

But the errors you posted above are all from the tests and examples sections of Casablanca. If Casablanca itself compiles just don't give a damn on the compilability of the examples.

In case you'll try to update boost these links might be helpful: https://stackoverflow.com/questions/33050113/how-to-install-boost-devel-1-59-in-centos7 https://gist.github.com/1duo/2d1d851f76f8297be264b52c1f31a2ab https://unix.stackexchange.com/questions/98918/how-to-install-a-custom-boost-version-in-centos

HTH

maaltan commented 6 years ago

I was able to get a boost 1.65.1 package to build and install into a non-system directory. How do i override the "find_package" search to use my local directory? Looking at the cmake documentation i should be able to define an environment variable "Boost_DIR" (or BOOST_DIR?) but it is not working. it still resolves to system directory. I have also tried using CMAKE_PREFIX_PATH.

https://cmake.org/cmake/help/v3.0/command/find_package.html

Sorry, i dont have much experience with cmake.

Also, since CentOS is a enterprise production server linux distribution, stability is valued over features so packages rarely update once released (outside of security updates)... At least that is my understanding.

maaltan commented 6 years ago

I found an answer my own question. you define BOOST_ROOT, but my cmake is too old to understand boost 1.65, so I'm going to try to find an older package.

marcoerdmann commented 6 years ago

OK, so here is how I build on CentOS 7:

This still gives you a lot of warnings, but Casablanca works basically.

If you want to link against Casablanca you might want to set e.g CPPRESTSDK_DIR=/opt/cpprest-2.10.2 so CMake's find_package() can detect it. And also you might want to add all the /lib directories (Boost, OpenSSL and C++ REST SDK) to LD_LIBRARY_PATH or add them under /etc/ld.so.conf.d/ and call /sbin/ldconfig.

Croftc commented 6 years ago

@maaltan any luck with an older version of boost? Running into the same issues.

PBRCW commented 6 years ago

The problem here is that boost V1.54 introduced some major changes and enhancements for ASIO, see here: http://www.boost.org/users/history/version_1_54_0.html You'll find a huge list of changes for ASIO and as the Unixoid part of the REST SDK relies on that changes being available you'll be out of luck when going with V1.53 or below. So if your OS comes with an overly old version of boost there's no alternative to updating it on your own. To what version you then update makes more or less no difference. I would suggest trying a recent version, you benefit from bugfixes and improvements. An exception may of course be if you compiler and/or standard library becomes so outdated that a recent boost doesn't support it anymore. E. g. they dropped support for the stone age GCC 2.9-branch some years ago. This is absolutely acceptable as the compiler and its standard library had so many issues and non-standard compliant stuff and people had long stopped using it in the wild. I once had to try to make boost operational for a very old version of VxWorks using that GCC 2.9, it almost drove me nuts.

crusader-mike commented 6 years ago

For benefit of those who has to go through similar pains -- here is list of steps to build and install cpprestsdk v2.9.1 and Azure Storage Client v4.0.0 on minimal CentOS 7 with GCC v6.2.0 (built from sources too). Took me a while to get it right:

- install boost
    sudo yum -y install zlib-devel libicu-devel
    cd ~
    wget https://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.gz
    tar -xzf boost_1_66_0.tar.gz
    cd boost_1_66_0
    ./bootstrap.sh --libdir=/usr/local/lib64 --with-libraries=system,thread,test,chrono,regex,date_time,filesystem,locale,random,atomic,log
    ./b2 -j 8 cxxflags="-Wno-deprecated-declarations -Wno-unused-function"
    sudo "PATH=$PATH" ./b2 install
- install Casablanca
    cd ~
    git clone https://github.com/Microsoft/cpprestsdk.git
    cd cpprestsdk
    git reset --hard v2.9.1
    mkdir Release/build.release
    cd Release/build.release
    CC=gcc CXX=g++ cmake .. -DCMAKE_BUILD_TYPE=Release -DWERROR=OFF -DBUILD_TESTS=OFF -DBUILD_SAMPLES=OFF
    !! apply this change to ~/cpprestsdk/Release/libs/websocketpp/websocketpp/transport/asio/connection.hpp:425: boost::asio::strand -> boost::asio::io_service::strand
    make -j 8
    sudo make install
    sudo mv /usr/local/lib/libcpprest* /usr/local/lib64/
    sudo ldconfig /usr/local/lib /usr/local/lib64/
- install Azure Storage Client for C++
    sudo yum -y install uuid-devel libxml2-devel
    cd ~
    git clone https://github.com/Azure/azure-storage-cpp.git
    cd azure-storage-cpp
    git reset --hard v4.0.0
    mkdir Microsoft.WindowsAzure.Storage/build.release
    cd Microsoft.WindowsAzure.Storage/build.release
    CC=gcc CXX=g++ cmake .. -DCMAKE_BUILD_TYPE=Release
    make -j 8
    sudo make install
    sudo mv /usr/local/lib/libazure* /usr/local/lib64/
    sudo ldconfig /usr/local/lib /usr/local/lib64/

Note: some cpprestsdk tests are failing, not sure if it ok

orest1 commented 6 years ago

I'm trying to compile Casablanca with the above, CentOS instructions and getting this compile error:

[ 15%] Building CXX object Release/src/CMakeFiles/cpprest.dir/pplx/threadpool.cpp.o
/root/gcp/azure/casablanca/Release/src/pplx/threadpool.cpp: In function ‘std::pair<bool, {anonymous}::threadpool_impl*> {anonymous}::initialize_shared_threadpool(size_t)’:
/root/gcp/azure/casablanca/Release/src/pplx/threadpool.cpp:143:12: error: ‘aligned_union’ in namespace ‘std’ does not name a type
     static std::aligned_union<0, platform_shared_threadpool>::type storage;
            ^
/root/gcp/azure/casablanca/Release/src/pplx/threadpool.cpp:145:56: error: ‘storage’ was not declared in this scope
         &reinterpret_cast<platform_shared_threadpool&>(storage);
                                                        ^
make[2]: *** [Release/src/CMakeFiles/cpprest.dir/pplx/threadpool.cpp.o] Error 1
make[1]: *** [Release/src/CMakeFiles/cpprest.dir/all] Error 2
make: *** [all] Error 2

Do you have any suggestions?

crusader-mike commented 6 years ago

A quote:

on minimal CentOS 7 with GCC v6.2.0 (built from sources too)

orest1 commented 6 years ago

Thank you, that solved that compile error, I'm getting now this error on a test but at least I got the libcpprest.so I need for azure build:

[ 55%] Building CXX object Release/tests/functional/http/listener/CMakeFiles/httplistener_test.dir/listener_construction_tests.cpp.o
/root/gcp/azure/casablanca/Release/tests/functional/http/listener/listener_construction_tests.cpp: In lambda function:
/root/gcp/azure/casablanca/Release/tests/functional/http/listener/listener_construction_tests.cpp:535:17: error: ‘class boost::asio::ssl::context’ has no member named ‘use_certificate_chain’; did you mean ‘use_certificate_file’?
             ctx.use_certificate_chain(cert);
                 ^~~~~~~~~~~~~~~~~~~~~
                 use_certificate_file
crusader-mike commented 6 years ago

not sure... wrong version of boost? I don't recall having problems compiling sdk tests...

orest1 commented 6 years ago

I'm using libboost: 1.68.0

crusader-mike commented 6 years ago

A quote:

Not sure if this is the root cause, but 1.66 worked for me...

BillyONeal commented 6 years ago

If aligned_storage is a missing piece, if someone wants to contribute a workaround that builds without so much pain on that platform we merge that...

orest1 commented 6 years ago

Trying to build azure-storage-cpp, is there any restrictions on Boost libs versions? I'm wondering because if there would be a restriction, cmake could check it. I'm using Boostlib 1.68.0, provided the "BOOST_LIBRARYDIR=/opt/boost/lib", the libs are all in there:

/opt/boost/lib/libboost_log.a
/opt/boost/lib/libboost_log_setup.a
/opt/boost/lib/libboost_log_setup.so
/opt/boost/lib/libboost_log_setup.so.1.68.0
/opt/boost/lib/libboost_log.so
/opt/boost/lib/libboost_log.so.1.68.0

however, I'm getting this error:

BOOST_LIBRARYDIR=/opt/boost/lib CASABLANCA_INCLUDE_DIR=../../../casablanca/Release/include CASABLANCA_LIBRARY=../../../casablanca/build.release/Release/Binaries CXX=/usr/bin/g++ cmake .. -DCMAKE_BUILD_TYPE=Release
CMake Error at /usr/share/cmake3/Modules/FindBoost.cmake:2044 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.53.0

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_log
          boost_log_setup

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR ...

Where is this " Boost version: 1.53.0" version# coming from?

BillyONeal commented 6 years ago

@orest1 Looks like it's a headers problem rather than a libraries problem. /usr/include probably has a 1.53.0 copy which doesn't match the .a files you're trying to use.

orest1 commented 6 years ago

@BillyONeal , thank you, however, shouldn't "BOOST_INCLUDEDIR=/opt/boost/include/boost" setting on the build cmake command line take precedence over the "/usr/include/boost"? here is the full command line:

BOOST_INCLUDEDIR=/opt/boost/include/boost BOOST_LIBRARYDIR=/opt/boost/lib CASABLANCA_INCLUDE_DIR=../../../casablanca/Release/include CASABLANCA_LIBRARY=../../../casablanca/build.release/Release/Binaries CXX=/usr/bin/g++ cmake .. -DCMAKE_BUILD_TYPE=Release
BillyONeal commented 6 years ago

@orest1 You're setting environment variables, CMake wants CMake defines. You need to move those after the cmake command and prepend with -D

BillyONeal commented 6 years ago

Unfortunately I'm not familiar with how azurestorage builds -- whenever I've built it I've just pointed cmake at it and all has been fine, sorry :(. Maybe you can ask those folks?

PBRCW commented 6 years ago

If aligned_storage is a missing piece, if someone wants to contribute a workaround that builds without so much pain on that platform we merge that...

As I don't use CentOS I cannot create such a patch, but maybe some other volunteer?

BillyONeal commented 6 years ago

@PBRCW Yes, a regular union is probably a good workaround. One member unions are a great way to control lifetime of a thing explicitly when one has to. I also don't use CentOS or I would attempt fixing it.

xzheng0702 commented 5 years ago

I'm trying to compile Casablanca with the above, CentOS instructions and getting this compile error:

[ 15%] Building CXX object Release/src/CMakeFiles/cpprest.dir/pplx/threadpool.cpp.o
/root/gcp/azure/casablanca/Release/src/pplx/threadpool.cpp: In function ‘std::pair<bool, {anonymous}::threadpool_impl*> {anonymous}::initialize_shared_threadpool(size_t)’:
/root/gcp/azure/casablanca/Release/src/pplx/threadpool.cpp:143:12: error: ‘aligned_union’ in namespace ‘std’ does not name a type
     static std::aligned_union<0, platform_shared_threadpool>::type storage;
            ^
/root/gcp/azure/casablanca/Release/src/pplx/threadpool.cpp:145:56: error: ‘storage’ was not declared in this scope
         &reinterpret_cast<platform_shared_threadpool&>(storage);
                                                        ^
make[2]: *** [Release/src/CMakeFiles/cpprest.dir/pplx/threadpool.cpp.o] Error 1
make[1]: *** [Release/src/CMakeFiles/cpprest.dir/all] Error 2
make: *** [all] Error 2

Do you have any suggestions?

I am having exactly the same error as you had. Were you able to fix them after you used GCC version higher than 6.2? I just updated the gcc to 7.3 but still getting the same error. Thanks