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.89k stars 1.63k forks source link

Embedded Linux Support? Yocto, RaspberryPi, OpenWRT #683

Open ScottDolan opened 6 years ago

ScottDolan commented 6 years ago

Does casablanca/cpprestsdk compile or run on any of the popular embedded linux OS.

I am tasked with writing application that needs to run on several different ARM based embedded linux OS such as Yocto, RaspberryPi, OpenWRT.. Has anyone successfully crossed compiled casablanca/cpprestsdk to any of those targets?

Is is possible?

ras0219-msft commented 6 years ago

I've personally cross compiled for raspberry pi. If you have issues, please report them!

gmgunderground commented 5 years ago

Hi, can someone, please explain me how to cross compile cpprestsdk for ARM under Linux Mint? G++ for ARM is just installed, but I'm unable to perform the task, probably my less knowledge about cmake doesn't help.

dimarusyy commented 5 years ago

I used linaro gcc available on rpi site(arm-linux-gnueabihf-gcc/arm-linux-gnueabihf-g++). Before running cmake, just specify CC/CXX to cross compiler path and run cmake generator. Btw, which ARM do you need to cross-compile ?

dimarusyy commented 5 years ago

See https://github.com/raspberrypi/tools for rpi.

gmgunderground commented 5 years ago

Hi, the ARM is a A9 from XILINX. The toolchain is ok I think. CMakeLists.txt is modified as follow

cmake_minimum_required(VERSION 3.1)
project(cpprestsdk-root NONE)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc-8)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++-8)

add_subdirectory(Release)

To compile I use cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=1

The problem at the moment is BOOST, I have the following error:

-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: /usr/bin/arm-linux-gnueabihf-gcc-8
-- Check for working C compiler: /usr/bin/arm-linux-gnueabihf-gcc-8 -- 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/arm-linux-gnueabihf-g++-8
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++-8 -- 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
-- websocketpp not found, using the embedded version
CMake Error at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1947 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.65.1

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_random
          boost_system
          boost_thread
          boost_filesystem
          boost_chrono
          boost_atomic
          boost_date_time
          boost_regex

  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.
Call Stack (most recent call first):
  Release/cmake/cpprest_find_boost.cmake:27 (find_package)
  Release/cmake/cpprest_find_websocketpp.cmake:15 (cpprest_find_boost)
  Release/src/CMakeLists.txt:67 (cpprest_find_websocketpp)

-- Found OpenSSL: /usr/lib/i386-linux-gnu/libcrypto.so (found suitable version "1.1.0g", minimum required is "1.0.0") 
-- Performing Test _SSL_LEAK_SUPPRESS_AVAILABLE
-- Performing Test _SSL_LEAK_SUPPRESS_AVAILABLE - Failed
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.11")
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.10/Modules/FindZLIB.cmake:112 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  Release/cmake/cpprest_find_zlib.cmake:15 (find_package)
  Release/src/CMakeLists.txt:80 (cpprest_find_zlib)

-- Configuring incomplete, errors occurred!
See also "/home/gmg/casablanca/build.arm.debug/CMakeFiles/CMakeOutput.log".
See also "/home/gmg/casablanca/build.arm.debug/CMakeFiles/CMakeError.log".

If I compile the the unmodified version of cpprestsdk (not for ARM) all is going fine, so boost is installed correctly.

gmgunderground commented 5 years ago

Also setting BOOST_LIBRARYDIR and BOOST_ROOT doesn't resolve the issue. G++ is ok because if I compile a simple HelloWorld and then export that file to the ARM is working correctly.

dimarusyy commented 5 years ago

Did you recompile boost with cross-compiler ?

gmgunderground commented 5 years ago

It's not automatically? What have I to do exactly?

dimarusyy commented 5 years ago

It is not automatic. cmake can't find boost libraries. I would try to recompile boost and feed it to cpprstsdk cmake.