aliyun / aliyun-oss-cpp-sdk

Aliyun OSS SDK for C++
Other
188 stars 88 forks source link

build Android #164

Open Ejefix opened 1 year ago

Ejefix commented 1 year ago
cmake -DCMAKE_TOOLCHAIN_FILE=/home/alex/Android/Sdk/ndk/26.0.10792818/build/cmake/android.toolchain.cmake \
      -DANDROID_NDK=/home/alex/Android/Sdk/ndk/26.0.10792818 \
      -DANDROID_ABI=arm64-v8a \
      -DANDROID_TOOLCHAIN=clang \
      -DANDROID_PLATFORM=android-21 \
      -DANDROID_STL=c++_shared \
      -DCMAKE_INSTALL_PREFIX=/home/alex/mylib \
      -G "Unix Makefiles" \
      -DCURL_LIBRARY=/home/alex/mylib/lib/libcurl.a \
      -DCURL_INCLUDE_DIR=/home/alex/mylib/include \
      -DZLIB_LIBRARY=/home/alex/clon/zlib/output/zlib-1.2.11/Release/arm64-v8a/lib/libz.a \
      -DZLIB_INCLUDE_DIR=/home/alex/clon/zlib/output/zlib-1.2.11/Release/arm64-v8a/include ..
-- The C compiler identification is Clang 17.0.2
-- The CXX compiler identification is Clang 17.0.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/alex/Android/Sdk/ndk/26.0.10792818/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/alex/Android/Sdk/ndk/26.0.10792818/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Project version: 1.9.1
-- TARGET_OS: ANDROID
-- Found CURL: /home/alex/mylib/lib/libcurl.a (found version "7.81.0")  
-- Found OpenSSL: /home/alex/Android/Sdk/ndk/26.0.10792818/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libcrypto.a (found version "1.1.1u")  
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    ZLIB_INCLUDE_DIR
    ZLIB_LIBRARY

-- Build files have been written to: /home/alex/clon/aliyun-oss-cpp-sdk/build

I'm doing this. After the 'make' command, I get this.

[ 99%] Building CXX object sample/CMakeFiles/cpp-sdk-sample.dir/src/LiveChannel/LiveChannelSample.cc.o
[100%] Linking CXX executable cpp-sdk-sample
ld.lld: error: undefined symbol: inflateInit_
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(deflate_init_writer) in archive /home/alex/mylib/lib/libcurl.a

ld.lld: error: undefined symbol: inflateEnd
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(deflate_close_writer) in archive /home/alex/mylib/lib/libcurl.a
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(process_trailer) in archive /home/alex/mylib/lib/libcurl.a
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(inflate_stream) in archive /home/alex/mylib/lib/libcurl.a
>>> referenced 8 more times

ld.lld: error: undefined symbol: inflate
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(inflate_stream) in archive /home/alex/mylib/lib/libcurl.a

ld.lld: error: undefined symbol: inflateInit2_
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(inflate_stream) in archive /home/alex/mylib/lib/libcurl.a
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(gzip_init_writer) in archive /home/alex/mylib/lib/libcurl.a
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(gzip_init_writer) in archive /home/alex/mylib/lib/libcurl.a

ld.lld: error: undefined symbol: zlibVersion
>>> referenced by content_encoding.c
>>>               libcurl_la-content_encoding.o:(gzip_init_writer) in archive /home/alex/mylib/lib/libcurl.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [sample/CMakeFiles/cpp-sdk-sample.dir/build.make:213: sample/cpp-sdk-sample] 
make[1]: *** [CMakeFiles/Makefile2:142: sample/CMakeFiles/cpp-sdk-sample.dir/all] 
make: *** [Makefile:136: all] 

What am I doing wrong? Why does it require zlib when I'm building curl?"

 ./configure --host aarch64-linux-android --with-pic --disable-shared --with-openssl="/home/alex/android_openssl/build" --with-zlib --prefix=/home/alex/mylib
make 
make install