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

build error: clang3.8 - boost1.54 - Ubuntu 14.04.5 LTS #372

Open FinchPowers opened 7 years ago

FinchPowers commented 7 years ago

Hi!

Is it supposed to build with clang or not? I saw issues and a branch related to it, so I'm unsure because on the other hand the doc only states "gcc".

So if it's not meant to work, here I have my answer. Otherwise, here is some of the errors I've got.

First, the exact compile command:

clang++-3.8 -fPIC -m64 -fno-omit-frame-pointer -msse3 -msse4.2 -Wall -Werror -Wno-sign-compare -Woverloaded-virtual -Wno-deprecated-declarations -Wno-deprecated -Winit-self -Qunused-arguments -Wno-mismatched-tags -Wno-unused-function -ftemplate-backtrace-limit=0 -pipe -ggdb -std=c++0x -fno-builtin-malloc -fno-builtin-calloc-fno-builtin-realloc -fno-builtin-free -o build/x86_64/obj/mldb/ext/casablanca/./Release/src/http/client/http_client_asio.cpp.9819bedd7c25b3339b1e1430acb29b55.lo -c ./mldb/ext/casablanca/./Release/src/http/client/http_client_asio.cpp -MP -MMD -MF build/x86_64/obj/mldb/ext/casablanca/./Release/src/http/client/http_client_asio.cpp.d -MQ build/x86_64/obj/mldb/ext/casablanca/./Release/src/http/client/http_client_asio.cpp.9819bedd7c25b3339b1e1430acb29b55.lo -O3 -DBOOST_DISABLE_ASSERTS -DNDEBUG -D_DEBUG -Imldb/ext/casablanca/Release/src/pch -Imldb/ext/casablanca/Release/include -Imldb/ext/casablanca/Release/libs -Wno-overloaded-virtual -Wno-unused-local-typedefs -Wno-unknown-pragmas -D_DEBUG -Imldb/ext/casablanca/Release/src/pch -Imldb/ext/casablanca/Release/include -Imldb/ext/casablanca/Release/libs -Wno-overloaded-virtual -Wno-unused-local-typedefs -Wno-unknown-pragmas

Then the build errors

./mldb/ext/casablanca/./Release/src/http/client/http_client_asio.cpp:44:2: error: "Cpp rest SDK requires c++11 smart pointer support from boost"
#error "Cpp rest SDK requires c++11 smart pointer support from boost"
 ^
./mldb/ext/casablanca/./Release/src/http/client/http_client_asio.cpp:1432:21: error: no matching member function for call to 'expires_from_now'
            m_timer.expires_from_now(m_duration);
            ~~~~~~~~^~~~~~~~~~~~~~~~

The output of clang++-3.8 -v is

clang version 3.8.0-2ubuntu3~trusty4 (tags/RELEASE_380/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.2.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

Lastly, if I rebuild everything with g++/gcc 4.8.5 instead, the same command works.

Any help is appreciated. Thanks!

SSE4 commented 6 years ago

I had very similar issue with Android NDK r16b (armv7, libc++):

[ 96%] Building CXX object cpprestsdk-2.10.1/Release/src/CMakeFiles/cpprest.dir/http/listener/http_server_asio.cpp.o
/home/sse4/.conan/data/cpprestsdk/2.10.1/bincrafters/testing/build/362f885c561e9e7387d7059684f2a74afba9979e/cpprestsdk-2.10.1/Release/src/http/client/http_client_asio.cpp:1559:21: error: no matching member function for call to 'expires_from_now'
            m_timer.expires_from_now(m_duration);
            ~~~~~~~~^~~~~~~~~~~~~~~~
/home/sse4/.conan/data/boost_asio/1.66.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/asio/include/boost/asio/basic_waitable_timer.hpp:578:15: note: candidate function not viable: no known conversion from 'boost::chrono::microseconds' (aka 'duration<long long, ratio<1LL, 1000000LL> >') to 'const
      boost::asio::basic_waitable_timer<std::__ndk1::chrono::steady_clock, boost::asio::wait_traits<std::__ndk1::chrono::steady_clock> >::duration' (aka 'const duration<long long, ratio<1LL, 1000000000LL> >') for 1st argument
  std::size_t expires_from_now(const duration& expiry_time)
              ^
/home/sse4/.conan/data/boost_asio/1.66.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/asio/include/boost/asio/basic_waitable_timer.hpp:550:12: note: candidate function not viable: requires 0 arguments, but 1 was provided
  duration expires_from_now() const
           ^
/home/sse4/.conan/data/boost_asio/1.66.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/asio/include/boost/asio/basic_waitable_timer.hpp:610:15: note: candidate function not viable: requires 2 arguments, but 1 was provided
  std::size_t expires_from_now(const duration& expiry_time,
              ^
/home/sse4/.conan/data/cpprestsdk/2.10.1/bincrafters/testing/build/362f885c561e9e7387d7059684f2a74afba9979e/cpprestsdk-2.10.1/Release/src/http/client/http_client_asio.cpp:1571:24: error: no matching member function for call to 'expires_from_now'
            if(m_timer.expires_from_now(m_duration) > 0)
               ~~~~~~~~^~~~~~~~~~~~~~~~
/home/sse4/.conan/data/boost_asio/1.66.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/asio/include/boost/asio/basic_waitable_timer.hpp:578:15: note: candidate function not viable: no known conversion from 'boost::chrono::microseconds' (aka 'duration<long long, ratio<1LL, 1000000LL> >') to 'const
      boost::asio::basic_waitable_timer<std::__ndk1::chrono::steady_clock, boost::asio::wait_traits<std::__ndk1::chrono::steady_clock> >::duration' (aka 'const duration<long long, ratio<1LL, 1000000000LL> >') for 1st argument
  std::size_t expires_from_now(const duration& expiry_time)
              ^
/home/sse4/.conan/data/boost_asio/1.66.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/asio/include/boost/asio/basic_waitable_timer.hpp:550:12: note: candidate function not viable: requires 0 arguments, but 1 was provided
  duration expires_from_now() const
           ^
/home/sse4/.conan/data/boost_asio/1.66.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/asio/include/boost/asio/basic_waitable_timer.hpp:610:15: note: candidate function not viable: requires 2 arguments, but 1 was provided
  std::size_t expires_from_now(const duration& expiry_time,
              ^
2 errors generated.
make[2]: *** [cpprestsdk-2.10.1/Release/src/CMakeFiles/cpprest.dir/http/client/http_client_asio.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [cpprestsdk-2.10.1/Release/src/CMakeFiles/cpprest.dir/all] Error 2
make: *** [all] Error 2

solved by patching Release/src/http/client/http_client_asio.cpp: replaced m_timer.expires_from_now(m_duration) via m_timer.expires_from_now(std::chrono::microseconds(m_duration.count()))

related to the https://github.com/bincrafters/community/issues/189