Open Nathan-M-code opened 11 months ago
Could you please try disabling zlib
for curl via -DCURL_ZLIB=OFF
?
Could you provide a bit if information on how to install NDK on Linux? Then I can have a look at it. But be aware, I do not have any android dev experience.
With -DCURL_ZLIB=OFF
it builded.
I have to say that I had to manually do that : https://github.com/libcpr/cpr/commit/eb2d418f86d6907d81d67d900e7cd518b2d6e34b
Or I got this error:
[100%] Linking CXX shared library ../lib/libcpr.so
ld.lld: error: unable to find library -lstdc++fs
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [cpr/CMakeFiles/cpr.dir/build.make:530: lib/libcpr.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:229: cpr/CMakeFiles/cpr.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
To use ndk, it is quite easy, manually download it at : https://developer.android.com/ndk/downloads
And add -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK="$ndkPath" -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
as parametre for your cmake cmd.
It will compile for android with the specified ndk
I didn't test the compiled libcpr yet, I'll let you know if everything is ok
Ah, linking to stdc++fs
was broken and is already fixed with the latest version on master. Could you please try master instead of the 1.10.5 release?
It worked without any error with ndk r25c (didn't try with r26b) ! Also I needed to set OFF SSL or I got
-- Detecting SSL backend...
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
-- Could NOT find MbedTLS (missing: MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
CMake Error at CMakeLists.txt:139 (message):
No valid SSL backend found! Please install OpenSSL, Mbed TLS or disable SSL
by setting CPR_ENABLE_SSL to OFF.
Same as #333 Why OpenSSL is not found the same way as if we build cpr without ndk ?
With this command on master:
cmake -S .. -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK="$ndkPath" -DCMAKE_INSTALL_PREFIX="$ndkPath/sources/third_party/cpr" -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_BUILD_TYPE=Release -DCPR_USE_SYSTEM_CURL=ON -DCURL_INCLUDE_DIR="/usr/include/x86_64-linux-gnu/curl" -DOPENSSL_INCLUDE_DIR="/usr/lib/ssl" ..
-- CXX standard: 17
-- C++ Requests CMake Options
-- =======================================================
-- CPR_GENERATE_COVERAGE: OFF
-- CPR_CURL_NOSIGNAL: OFF
-- CURL_VERBOSE_LOGGING: OFF
-- CPR_USE_SYSTEM_GTEST: OFF
-- CPR_USE_SYSTEM_CURL: ON
-- CPR_ENABLE_CURL_HTTP_ONLY: ON
-- CPR_ENABLE_SSL: ON
-- CPR_FORCE_OPENSSL_BACKEND: OFF
-- CPR_FORCE_WINSSL_BACKEND: OFF
-- CPR_FORCE_DARWINSSL_BACKEND: OFF
-- CPR_FORCE_MBEDTLS_BACKEND: OFF
-- CPR_ENABLE_LINTING: OFF
-- CPR_ENABLE_CPPCHECK: OFF
-- CPR_BUILD_TESTS: OFF
-- CPR_BUILD_TESTS_SSL: OFF
-- CPR_BUILD_TESTS_PROXY: OFF
-- CPR_SKIP_CA_BUNDLE_SEARCH: OFF
-- CPR_USE_BOOST_FILESYSTEM: OFF
-- CPR_DEBUG_SANITIZER_FLAG_THREAD: OFF
-- CPR_DEBUG_SANITIZER_FLAG_ADDR: OFF
-- CPR_DEBUG_SANITIZER_FLAG_LEAK: OFF
-- CPR_DEBUG_SANITIZER_FLAG_UB: OFF
-- CPR_DEBUG_SANITIZER_FLAG_ALL: OFF
-- =======================================================
-- Automatically detecting SSL backend.
-- Detecting SSL backend...
-- SSL auto detect: Using OpenSSL.
-- Curl found on this system.
-- Configuring done (0.4s)
CMake Error at cpr/CMakeLists.txt:39 (target_link_libraries):
Target "cpr" links to:
OpenSSL::SSL
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
-- Generating done (0.0s)
CMake Generate step failed. Build files cannot be regenerated correctly.
[ 3%] Building CXX object cpr/CMakeFiles/cpr.dir/accept_encoding.cpp.o
In file included from /home/me/Desktop/dev/FactoryCapi/FactoryCapi_game/external_deps/cpr/cpr/accept_encoding.cpp:1:
/home/me/Desktop/dev/FactoryCapi/FactoryCapi_game/external_deps/cpr/include/cpr/accept_encoding.h:4:10: fatal error: 'curl/curlver.h' file not found
#include <curl/curlver.h>
^~~~~~~~~~~~~~~~
1 error generated.
gmake[2]: *** [cpr/CMakeFiles/cpr.dir/build.make:76: cpr/CMakeFiles/cpr.dir/accept_encoding.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:116: cpr/CMakeFiles/cpr.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
-- Install configuration: "Release"
CMake Error at cpr/cmake_install.cmake:52 (file):
file INSTALL cannot find
"/home/me/Desktop/dev/FactoryCapi/FactoryCapi_game/external_deps/cpr/build_android/lib/libcpr.so":
No such file or directory.
Call Stack (most recent call first):
cmake_install.cmake:47 (include)
With -DCPR_USE_SYSTEM_CURL=OFF
I have got another error:
-- Looking for SSL_set0_wbio
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OPENSSL_SSL_LIBRARY
linked by target "cmTC_faf7e" in directory /home/me/Desktop/dev/FactoryCapi/FactoryCapi_game/external_deps/cpr/build_android/CMakeFiles/CMakeScratch/TryCompile-9tboxN
CMake Error at /usr/share/cmake-3.27/Modules/CheckSymbolExists.cmake:140 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
/usr/share/cmake-3.27/Modules/CheckSymbolExists.cmake:66 (__CHECK_SYMBOL_EXISTS_IMPL)
build_android/_deps/curl-src/CMakeLists.txt:646 (check_symbol_exists)
build_android/_deps/curl-src/CMakeLists.txt:652 (openssl_check_symbol_exists)
TLDR: OpenSSL Detection is not working correctly. You have to set it manually like we are doing it for macOS inside the CI: https://github.com/libcpr/cpr/blob/1ad1cd2daf138aefdcdb1c35d99608387d230ec1/.github/workflows/ci.yml#L256-L257
FYI, if you use vckpkg it has an older version (1.10.5#2), I've created an issue to update cpr to 1.11.0 which seems like fixing NDK linking issue. https://github.com/microsoft/vcpkg/issues/41876
Description
Example/How to Reproduce
I would like to add that if I remove
-DCPR_ENABLE_SSL=OFF
, I have the same error as #333 and I couldn't find a fixPossible Fix
No response
Where did you get it from?
GitHub (1.10.5)
Additional Context/Your Environment