Skip to content

Creating libaws-iot-sdk-cpp for Android #35

@chaunnt

Description

@chaunnt

Can I use this library for Android project ?
I have C++ project that will use this library.
Everything in Linux 14.04 desktop is OK
When I cross-compile this project for Android
it can not find -laws-iot-sdk-cpp
I also put library to lib folder of toolchain or /usr/local/lib and include all header file of library.
Questions are:

  • Can I use this library for C++ project but cross-compile for Android ? (I'm using Qt)
  • Can I build this library as shared library (file .so) with cross compiler ?

Note:

  1. I added some texts to cmake files but failed

set(CMAKE_SYSTEM_NAME Android)

set(CMAKE_SYSTEM_VERSION 1)

set(CMAKE_C_COMPILER /opt/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-gcc)
set(CMAKE_CXX_COMPILER /opt/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-g++)

  1. I also tried Cross-Compile with Cmake command (Removed text in cmake files of Note .1

/opt/cmake/bin/cmake ../. -DCMAKE_TOOLCHAIN_FILE=//home/nntchau/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake

Output is as below

-- Android: Selected GCC toolchain 'arm-linux-androideabi-4.9'
-- Check for working CXX compiler: //home/nntchau/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
-- Check for working CXX compiler: //home/nntchau/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -- broken
CMake Error at /opt/cmake/share/cmake-3.8/Modules/CMakeTestCXXCompiler.cmake:44 (message):
The C++ compiler
"//home/nntchau/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++"
is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/nntchau/aws-iot-device-sdk-cpp-1.1.1/build_share/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_2027d/fast"

/usr/bin/make -f CMakeFiles/cmTC_2027d.dir/build.make
CMakeFiles/cmTC_2027d.dir/build

make[1]: Entering directory
`/home/nntchau/aws-iot-device-sdk-cpp-1.1.1/build_share/CMakeFiles/CMakeTmp'

Building CXX object CMakeFiles/cmTC_2027d.dir/testCXXCompiler.cxx.o

//home/nntchau/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
--target=armv7-none-linux-androideabi
--sysroot=//home/nntchau/Android/Sdk/ndk-bundle/platforms/android-9/arch-arm
-isystem
//home/nntchau/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include
-isystem
//home/nntchau/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include
-isystem
//home/nntchau/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
-isystem
//home/nntchau/Android/Sdk/ndk-bundle/platforms/android-9/arch-arm/usr/include
-g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong
-no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
-fno-integrated-as -mthumb -Wa,--noexecstack -Wformat
-Werror=format-security -O0 -fno-limit-debug-info -o
CMakeFiles/cmTC_2027d.dir/testCXXCompiler.cxx.o -c
/home/nntchau/aws-iot-device-sdk-cpp-1.1.1/build_share/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

arm-linux-androideabi-g++: error: unrecognized command line option
'-fno-integrated-as'

arm-linux-androideabi-g++: error: unrecognized command line option
'-fno-limit-debug-info'

make[1]: *** [CMakeFiles/cmTC_2027d.dir/testCXXCompiler.cxx.o] Error 1

make[1]: Leaving directory
`/home/nntchau/aws-iot-device-sdk-cpp-1.1.1/build_share/CMakeFiles/CMakeTmp'

make: *** [cmTC_2027d/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions