Compiling libcurl for Android 64 - android

I'm trying to create a Android 64-bit libcurl static library with SSL support.
I first compile OpenSSL with the help of this script https://github.com/cocochpie/android-openssl/blob/master/build-all-arch.sh. I've modified it so that it only builds for Android 64-bit and I see the following output:
ANDROID_TOOLS = aarch64-linux-android-gcc aarch64-linux-android-gcc-ranlib aarch64-linux-android-ld
Error: ANDROID_SYSROOT is not valid. Please edit this script.
CHECK_CROSS_COMPILER =
arch = arm64
ANDROID_NDK_ROOT: /opt/android/ndk-bundle
ANDROID_ARCH: arch-arm64
ANDROID_EABI: aarch64-linux-android-4.9
ANDROID_API: android-19
ANDROID_SYSROOT: /opt/android/ndk-bundle/platforms/android-19/arch-arm64
ANDROID_TOOLCHAIN: /opt/android/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin
FIPS_SIG: /openssl-1.1.0g/util/incore
CROSS_COMPILE:
ANDROID_DEV: /opt/android/ndk-bundle/platforms/android-19/arch-arm64/usr
CROSS COMPILE ENV :
Can't open Makefile.org: No such file or directory.
Configuring OpenSSL version 1.1.0g (0x1010007fL)
no-afalgeng [forced] OPENSSL_NO_AFALGENG
no-apps [forced] OPENSSL_NO_APPS
no-asan [default] OPENSSL_NO_ASAN
no-asm [option] OPENSSL_NO_ASM
no-capieng [forced] OPENSSL_NO_CAPIENG
no-comp [option] OPENSSL_NO_COMP (skip dir)
no-crypto-mdebug [default] OPENSSL_NO_CRYPTO_MDEBUG
no-crypto-mdebug-backtrace [default] OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
no-dynamic-engine [forced]
no-ec_nistp_64_gcc_128 [default] OPENSSL_NO_EC_NISTP_64_GCC_128
no-egd [default] OPENSSL_NO_EGD
no-engine [option] OPENSSL_NO_ENGINE (skip engines)
no-fuzz-afl [default] OPENSSL_NO_FUZZ_AFL
no-fuzz-libfuzzer [default] OPENSSL_NO_FUZZ_LIBFUZZER
no-heartbeats [default] OPENSSL_NO_HEARTBEATS
no-hw [option] OPENSSL_NO_HW
no-md2 [default] OPENSSL_NO_MD2 (skip dir)
no-msan [default] OPENSSL_NO_MSAN
no-rc5 [default] OPENSSL_NO_RC5 (skip dir)
no-sctp [default] OPENSSL_NO_SCTP
no-shared [option]
no-ssl-trace [default] OPENSSL_NO_SSL_TRACE
no-ssl3 [option] OPENSSL_NO_SSL3
no-ssl3-method [default] OPENSSL_NO_SSL3_METHOD
no-stdio [option] OPENSSL_NO_STDIO
no-tests [forced] OPENSSL_NO_TESTS
no-threads [option]
no-ubsan [default] OPENSSL_NO_UBSAN
no-unit-test [default] OPENSSL_NO_UNIT_TEST
no-weak-ssl-ciphers [default] OPENSSL_NO_WEAK_SSL_CIPHERS
no-zlib [option]
no-zlib-dynamic [default]
Configuring for linux-generic64
CC =arm-linux-androideabi-gcc
CFLAG =-Wall -O3 -fPIC -mandroid -I/opt/android/ndk-bundle/platforms/android-19/arch-arm64/usr/include -B/opt/android/ndk-bundle/platforms/android-19/arch-arm64/usr//lib -O3 -fomit-frame-pointer -Wall
SHARED_CFLAG =-fPIC -DOPENSSL_USE_NODELETE
DEFINES =DSO_DLFCN HAVE_DLFCN_H NDEBUG OPENSSL_NO_DYNAMIC_ENGINE OPENSSL_PIC B_ENDIAN SHARED_EXTENSION=.so OPENSSL_PIC DSO_DLFCN HAVE_DLFCN_H
LFLAG =
PLIB_LFLAG =
EX_LIBS =-ldl
APPS_OBJ =
CPUID_OBJ =mem_clr.o
UPLINK_OBJ =
BN_ASM =bn_asm.o
EC_ASM =
DES_ENC =des_enc.o fcrypt_b.o
AES_ENC =aes_core.o aes_cbc.o
BF_ENC =bf_enc.o
CAST_ENC =c_enc.o
RC4_ENC =rc4_enc.o rc4_skey.o
RC5_ENC =rc5_enc.o
MD5_OBJ_ASM =
SHA1_OBJ_ASM =
RMD160_OBJ_ASM=
CMLL_ENC =camellia.o cmll_misc.o cmll_cbc.o
MODES_OBJ =
PADLOCK_OBJ =
CHACHA_ENC =chacha_enc.o
POLY1305_OBJ =
BLAKE2_OBJ =
PROCESSOR =
RANLIB =arm-linux-androideabi-ranlib
ARFLAGS =
PERL =/usr/bin/perl
This step appears to complete successfully as the /openssl-1.1.0g directory ends up with a libssl.a and libcrypto.a as I would expect.
I then download curl and run the following configuration:
./configure \
--host=$CHOST \
--target=aarch64-linux-android \
--with-ssl=/openssl-1.1.0g \
--with-zlib \
--enable-ftp \
--enable-http \
--enable-ipv6 \
--enable-static \
--disable-dict \
--disable-file \
--disable-gopher \
--disable-imap \
--disable-ldap \
--disable-ldaps \
--disable-manual \
--disable-pop3 \
--disable-proxy \
--disable-rtsp \
--disable-shared \
--disable-smb \
--disable-smtp \
--disable-sspi \
--disable-telnet \
--disable-tftp \
--without-gnutls \
--without-libidn \
--without-librtmp
The output of this command is:
curl version: 7.56.1
Host setup: aarch64-unknown-linux-android
Install prefix: /usr/local
Compiler: arm-linux-androideabi-gcc
SSL support: no (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} )
SSH support: no (--with-libssh2)
zlib support: enabled
GSS-API support: no (--with-gssapi)
TLS-SRP support: no (--enable-tls-srp)
resolver: POSIX threaded
IPv6 support: enabled
Unix sockets support: enabled
IDN support: no (--with-{libidn2,winidn})
Build libcurl: Shared=no, Static=yes
Built-in manual: no (--enable-manual)
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
SSPI support: no (--enable-sspi)
ca cert bundle: no
ca cert path: no
ca fallback: no
LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS support: no (--enable-ldaps)
RTSP support: no (--enable-rtsp)
RTMP support: no (--with-librtmp)
metalink support: no (--with-libmetalink)
PSL support: no (libpsl not found)
HTTP2 support: disabled (--with-nghttp2)
Protocols: FTP HTTP
If I'm interpreting this correctly the libcurl config is not finding the SSL library and building without SSL support.
Is that correct? If so, I would guess that this would happen if a) it cannot find the required files or b) it does find the required files but they are compiled for a different architecture.
Can someone point out where I'm going wrong here?
UPDATE 1
As suggested I looked through the config.log file. This part looks suspicious:
COLLECT_GCC_OPTIONS='-o' 'conftest' '-v' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfp' '-mthumb' '-D' '__ANDROID_API__=19' '-Werror=implicit-function-declaration' '-O2' '-Wno-system-headers' '-v' '-mandroid' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfp' '-mthumb' '-D' '__ANDROID_API__=19' '-D' 'ANDROID' '-I' '/openssl-1.1.0g/include' '-I' '/openssl-1.1.0g/include/openssl' '-L/opt/android/toolchain-arm/include' '-march=armv7-a' '-L/openssl-1.1.0g/lib' '-mtls-dialect=gnu'
/opt/android/toolchain-arm/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/collect2 -plugin /opt/android/toolchain-arm/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/liblto_plugin.so -plugin-opt=/opt/android/toolchain-arm/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper -plugin-opt=-fresolution=/tmp/ccFgY2c5.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-ldl -plugin-opt=-pass-through=-lgcc --sysroot=/opt/android/toolchain-arm/sysroot --eh-frame-hdr -dynamic-linker /system/bin/linker -X -m armelf_linux_eabi -z noexecstack -z relro -z now -o conftest /opt/android/toolchain-arm/sysroot/usr/lib/crtbegin_dynamic.o -L/opt/android/toolchain-arm/include -L/openssl-1.1.0g/lib -L/opt/android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb -L/opt/android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb -L/opt/android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x -L/opt/android/toolchain-arm/bin/../lib/gcc -L/opt/android/toolchain-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib -L/opt/android/toolchain-arm/sysroot/usr/lib --fix-cortex-a8 /tmp/ccxx0SSC.o -lcrypto -lz -lgcc -lc -ldl -lgcc /opt/android/toolchain-arm/sysroot/usr/lib/crtend_android.o
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stdin'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function close_console: error: undefined reference to 'stderr'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stdin'
/openssl-1.1.0g/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'stderr'
collect2: error: ld returned 1 exit status

I managed to find a fantastic script for building what I needed: https://github.com/leenjewel/openssl_for_ios_and_android.
The big take away for me here was that if you see 'SSL support: no' and you are expecting to see 'yes' then it's one of two things: 1) it cannot find the path to SSL or 2) the path might be there but the compiled SSL is for the wrong architecture.
As Daniel Stenberg mentioned config.log is your friend here.

Related

Fatal error: 'config.h' file not found in react-native#0.68

I am trying to run a simple react native app on iOS. Recently React Native community have showed up some big updates, I guess that problem raised because of this new version. Because I just init new project and tried to run on iOS, it just throws error, On android its working fine but iOS isn't working. I have tried every solution but the question that peoples posted are lower version then 0.68 I guess, And there is a lot changes in react-native#0.68. Here is my react native info:
System:
OS: macOS 12.4
CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU # 3.10GHz
Memory: 39.15 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - /usr/local/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 8.10.0 - /usr/local/bin/npm
Watchman: 2022.06.13.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8512546
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
#react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
AND HERE IS THE OUTPUT AFTER RUNNING npx react-native run-is
yarn run v1.22.18
$ react-native run-ios
info Found Xcode workspace "carchaze.xcworkspace"
info Building (using "xcodebuild -workspace carchaze.xcworkspace -configuration Debug -scheme carchaze -destination id=281B8E0D-0F76-4F58-9290-06986344B5AA")
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening carchaze.xcworkspace.
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace carchaze.xcworkspace -configuration Debug -scheme carchaze -destination id=281B8E0D-0F76-4F58-9290-06986344B5AA
User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES
note: Using new build system
note: Planning
Analyze workspace
Create build description
Build description signature: 24ae75df6fda02487e58c5e870d14769
Build description path: /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/XCBuildData/24ae75df6fda02487e58c5e870d14769-desc.xcbuild
note: Build preparation complete
note: Building targets in dependency order
CompileC /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/Objects-normal/x86_64/libevent-dummy.o /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Target\ Support\ Files/libevent/libevent-dummy.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'libevent' from project 'Pods')
cd /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods
export LANG\=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -target x86_64-apple-ios11.0-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu11 -fobjc-arc -fmodules -fmodules-cache-path\=/Users/atifkhan/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/atifkhan/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -DPOD_CONFIGURATION_DEBUG\=1 -DDEBUG\=1 -DCOCOAPODS\=1 -DOBJC_OLD_DISPATCH_PROTOTYPES\=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability -fobjc-abi-version\=2 -fobjc-legacy-dispatch -index-store-path /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Index/DataStore -iquote /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/libevent-generated-files.hmap -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/libevent-own-target-headers.hmap -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/libevent-all-non-framework-target-headers.hmap -ivfsoverlay /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/all-product-headers.yaml -iquote /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/libevent-project-headers.hmap -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Products/Debug-iphonesimulator/libevent/include -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Private -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Private/libevent -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Public -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Public/libevent -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/libevent/include -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/DerivedSources-normal/x86_64 -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/DerivedSources/x86_64 -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/DerivedSources -F/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Products/Debug-iphonesimulator/libevent -include /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Target\ Support\ Files/libevent/libevent-prefix.pch -MMD -MT dependencies -MF /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/Objects-normal/x86_64/libevent-dummy.d --serialize-diagnostics /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/Objects-normal/x86_64/libevent-dummy.dia -c /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Target\ Support\ Files/libevent/libevent-dummy.m -o /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/Objects-normal/x86_64/libevent-dummy.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/libevent.build/Objects-normal/x86_64/libevent-dummy.o
CompileC /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/vlog_is_on.o /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/vlog_is_on.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'glog' from project 'Pods')
cd /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods
export LANG\=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-ios11.0-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu++14 -stdlib\=libc++ -fmodules -fmodules-cache-path\=/Users/atifkhan/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/atifkhan/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Werror\=deprecated-objc-isa-usage -Werror\=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DPOD_CONFIGURATION_DEBUG\=1 -DDEBUG\=1 -DCOCOAPODS\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Index/DataStore -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Products/Debug-iphonesimulator/glog/include -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Private -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Private/glog -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Public -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Public/glog -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources-normal/x86_64 -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources/x86_64 -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources -F/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Products/Debug-iphonesimulator/glog -Wno-shorten-64-to-32 -include /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Target\ Support\ Files/glog/glog-prefix.pch -MMD -MT dependencies -MF /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/vlog_is_on.d --serialize-diagnostics /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/vlog_is_on.dia -c /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/vlog_is_on.cc -o /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/vlog_is_on.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/vlog_is_on.o
In file included from /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/vlog_is_on.cc:35:
In file included from /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/utilities.h:73:
/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/base/mutex.h:105:10: fatal error: 'config.h' file not found
#include "config.h" // to figure out pthreads support
^~~~~~~~~~
1 error generated.
CompileC /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/utilities.o /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/utilities.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'glog' from project 'Pods')
cd /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods
export LANG\=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-ios11.0-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu++14 -stdlib\=libc++ -fmodules -fmodules-cache-path\=/Users/atifkhan/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/atifkhan/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Werror\=deprecated-objc-isa-usage -Werror\=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DPOD_CONFIGURATION_DEBUG\=1 -DDEBUG\=1 -DCOCOAPODS\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Index/DataStore -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Products/Debug-iphonesimulator/glog/include -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Private -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Private/glog -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Public -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Public/glog -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources-normal/x86_64 -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources/x86_64 -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources -F/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Products/Debug-iphonesimulator/glog -Wno-shorten-64-to-32 -include /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Target\ Support\ Files/glog/glog-prefix.pch -MMD -MT dependencies -MF /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/utilities.d --serialize-diagnostics /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/utilities.dia -c /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/utilities.cc -o /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/utilities.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/utilities.o
In file included from /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/utilities.cc:32:
In file included from /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/utilities.h:73:
/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/base/mutex.h:105:10: fatal error: 'config.h' file not found
#include "config.h" // to figure out pthreads support
^~~~~~~~~~
1 error generated.
CompileC /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/symbolize.o /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/symbolize.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'glog' from project 'Pods')
cd /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods
export LANG\=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-ios11.0-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu++14 -stdlib\=libc++ -fmodules -fmodules-cache-path\=/Users/atifkhan/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/atifkhan/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Werror\=deprecated-objc-isa-usage -Werror\=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DPOD_CONFIGURATION_DEBUG\=1 -DDEBUG\=1 -DCOCOAPODS\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Index/DataStore -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Products/Debug-iphonesimulator/glog/include -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Private -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Private/glog -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Public -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Headers/Public/glog -I/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources-normal/x86_64 -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources/x86_64 -I/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/DerivedSources -F/Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Products/Debug-iphonesimulator/glog -Wno-shorten-64-to-32 -include /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/Target\ Support\ Files/glog/glog-prefix.pch -MMD -MT dependencies -MF /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/symbolize.d --serialize-diagnostics /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/symbolize.dia -c /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/symbolize.cc -o /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/symbolize.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/symbolize.o
In file included from /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/symbolize.cc:55:
In file included from /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/utilities.h:73:
/Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/base/mutex.h:105:10: fatal error: 'config.h' file not found
#include "config.h" // to figure out pthreads support
^~~~~~~~~~
1 error generated.
2022-06-19 22:38:25.298 xcodebuild[40727:215217] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-06-19 22:38:25.298 xcodebuild[40727:215217] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
** BUILD FAILED **
The following build commands failed:
CompileC /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/vlog_is_on.o /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/vlog_is_on.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'glog' from project 'Pods')
CompileC /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/utilities.o /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/utilities.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'glog' from project 'Pods')
CompileC /Users/atifkhan/Library/Developer/Xcode/DerivedData/carchaze-falkqfsrsbarnffmcealtkufybsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/glog.build/Objects-normal/x86_64/symbolize.o /Users/atifkhan/Downloads/project/React_Native_Projects/Carchaze/carchaze/ios/Pods/glog/src/symbolize.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'glog' from project 'Pods')
(3 failures)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
It's frustrating, I work on it over 7 hours. I have read a lot of docs, but still didn't find any solution. It would be pleasure if someone have the solution of it.
I did a lot of research, but suddenly i saw a pkg called react-native-clean-project. I just run this command in my project directory npx react-native-clean-project and then just yarn run ios my project run successfully. I have no idea what this pkg did, but for sure it didn't downgrade my pkg, react-native is still on latest version and project is now running on IOS & Android both. This pkg is a lot helpful

libvalhalla cmake link static library Android

Directory pic:
This is how I compile protobuf:
export NDK=~/Android/Sdk/ndk/23.1.7779620
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
export TARGET=x86_64-linux-android
export API=26
export AR=$TOOLCHAIN/bin/llvm-ar
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export AS=$CC
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/ld
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export STRIP=$TOOLCHAIN/bin/llvm-strip
export LDFLAGS="-llog -fPIC"
export CXXFLAGS="-fPIC"
../protobuf-3.19.0/configure --host $TARGET --disable-shared --with-pic
make -j$(nproc)
This is how I compile valhalla:
export PROTOBUF_INSTALL_DIR=/opt/protobuf
export PROTOBUF_HEADERS=$PROTOBUF_INSTALL_DIR/include
export PROTOC=$PROTOBUF_INSTALL_DIR/bin/protoc
export PROTOBUF_LIB=../protobuf_android/src/.libs # static libs that got generated from previous build script
export NDK=~/Android/Sdk/ndk/23.1.7779620
export TOOLCHAIN=$NDK/build/cmake/android.toolchain.cmake
cmake ../valhalla \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_PLATFORM="android-26" \
-DANDROID_ABI="x86_64" \
-DANDROID_NDK="$NDK" \
-DANDROID_TOOLCHAIN=clang++ \
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" \
-DENABLE_PYTHON_BINDINGS=Off \
-DProtobuf_PROTOC_EXECUTABLE=$PROTOC \
-DProtobuf_INCLUDE_DIR=$PROTOBUF_HEADERS \
-DProtobuf_LIBRARY_RELEASE=$PROTOBUF_LIB \
-DENABLE_TOOLS=Off \
-DENABLE_HTTP=Off \
-DENABLE_SERVICES=Off \
-DENABLE_DATA_TOOLS=Off \
-DENABLE_STATIC_LIBRARY_MODULES=On \
-DBUILD_SHARED_LIBS=Off \
-DBoost_INCLUDE_DIR=${HOME}/Documents/routing/boost-1.77.0/
make -j$(nproc)
And the CMakeLists.txt
cmake_minimum_required(VERSION 3.12.1)
project(react-native)
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES native-lib.cpp)
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(ANDROID_ABI_LIBS ${CMAKE_SOURCE_DIR}/lib/${ANDROID_ABI})
include_directories(${INCLUDE_DIR})
# Add source files
add_library(react-native SHARED ${SOURCE_FILES})
# libvalhalla import
add_library(libvalhalla STATIC IMPORTED)
set_target_properties(libvalhalla PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla.a)
# valhalla-baldr
add_library(valhalla-baldr STATIC IMPORTED)
set_target_properties(valhalla-baldr PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/baldr/libvalhalla-baldr.a)
# valhalla-loki
add_library(valhalla-loki STATIC IMPORTED)
set_target_properties(valhalla-loki PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-loki.a)
# valhalla-meili
add_library(valhalla-meili STATIC IMPORTED)
set_target_properties(valhalla-meili PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-meili.a)
# valhalla-midgard
add_library(valhalla-midgard STATIC IMPORTED)
set_target_properties(valhalla-midgard PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-midgard.a)
# valhalla-odin
add_library(valhalla-odin STATIC IMPORTED)
set_target_properties(valhalla-odin PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-odin.a)
# valhalla-sif
add_library(valhalla-sif STATIC IMPORTED)
set_target_properties(valhalla-sif PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-sif.a)
# valhalla-skadi
add_library(valhalla-skadi STATIC IMPORTED)
set_target_properties(valhalla-skadi PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-skadi.a)
# valhalla-tyr
add_library(valhalla-tyr STATIC IMPORTED)
set_target_properties(valhalla-tyr PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-tyr.a)
# valhalla-thor
add_library(valhalla-thor STATIC IMPORTED)
set_target_properties(valhalla-thor PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-thor.a)
# libprotobuf
add_library(libprotobuf STATIC IMPORTED)
set_target_properties(libprotobuf PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libprotobuf.a)
# libvalhalla-proto
add_library(libvalhalla-proto STATIC IMPORTED)
set_target_properties(libvalhalla-proto PROPERTIES IMPORTED_LOCATION
${ANDROID_ABI_LIBS}/libvalhalla-proto.a)
file(GLOB_RECURSE Foo_HEADERS CONFIGURE_DEPENDS "src/*.h")
set(Foo_INCLUDE_DIRS "")
foreach (_headerFile ${Foo_HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list(APPEND Foo_INCLUDE_DIRS ${_dir})
endforeach ()
list(REMOVE_DUPLICATES Foo_INCLUDE_DIRS)
target_include_directories(react-native PUBLIC
${ANDROID_ABI_LIBS}/valhalla
${ANDROID_ABI_LIBS}/valhalla/proto
${ANDROID_ABI_LIBS}/google/protobuf
${ANDROID_ABI_LIBS}/baldr
${Foo_INCLUDE_DIRS}
logger)
target_link_libraries(valhalla-tyr INTERFACE
valhalla-baldr
valhalla-loki
valhalla-thor
valhalla-odin
valhalla-proto)
target_link_libraries(valhalla-loki INTERFACE
valhalla-tyr)
find_library(log-lib log android)
target_link_libraries(react-native
-Wl,--start-group
libvalhalla
valhalla-baldr
valhalla-thor
valhalla-meili
valhalla-odin
valhalla-sif
valhalla-skadi
valhalla-tyr
valhalla-midgard
libprotobuf
libvalhalla-proto
-Wl,--end-group
log
${log-lib}
android)
Stackrace Android Studio:
Build command failed.
Error while executing process /usr/bin/ninja with arguments {-C app/.cxx/Release/231y4r2y/x86_64 react-native}
ninja: Entering directory `app/.cxx/Release/231y4r2y/x86_64'
[1/2] Building CXX object CMakeFiles/react-native.dir/native-lib.cpp.o
Android (7019983 based on r365631c3) clang version 9.0.9 (https://android.googlesource.com/toolchain/llvm-project a2a1e703c0edb03ba29944e529ccbf457742737b) (based on LLVM 9.0.9svn)
Target: x86_64-none-linux-android26
Thread model: posix
InstalledDir: ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9.x
Found candidate GCC installation: ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x
Selected GCC installation: ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x
Candidate multilib: .;#m64
Selected multilib: .;#m64
"~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++" -cc1 -triple x86_64-none-linux-android26 -emit-obj -mnoexecstack -disable-free -disable-llvm-verifier -discard-value-names -main-file-name native-lib.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-feature +sse4.2 -target-feature +popcnt -target-feature +cx16 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -momit-leaf-frame-pointer -v -ffunction-sections -fdata-sections -coverage-notes-file app/.cxx/Release/231y4r2y/x86_64/CMakeFiles/react-native.dir/native-lib.cpp.gcno -resource-dir ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9 -dependency-file CMakeFiles/react-native.dir/native-lib.cpp.o.d -sys-header-deps -MT CMakeFiles/react-native.dir/native-lib.cpp.o -D react_native_EXPORTS -I app/src/main/cpp/include -D ANDROID -D _FORTIFY_SOURCE=2 -D NDEBUG -isysroot ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot -internal-isystem ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1 -internal-isystem ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include -internal-isystem ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/include -internal-externc-isystem ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/x86_64-linux-android -internal-externc-isystem ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/include -internal-externc-isystem ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -O2 -Wformat -Werror=format-security -std=gnu++14 -fdeprecated-macro -fdebug-compilation-dir app/.cxx/Release/231y4r2y/x86_64 -ferror-limit 19 -fmessage-length 0 -stack-protector 2 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o CMakeFiles/react-native.dir/native-lib.cpp.o -x c++ app/src/main/cpp/native-lib.cpp
clang -cc1 version 9.0.9 based upon LLVM 9.0.9svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/include"
#include "..." search starts here:
#include <...> search starts here:
app/src/main/cpp/include
~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1
~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include
~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/include
~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/x86_64-linux-android
~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
End of search list.
[2/2] Linking CXX shared library app/build/intermediates/cxx/Release/231y4r2y/obj/x86_64/libreact-native.so
FAILED: app/build/intermediates/cxx/Release/231y4r2y/obj/x86_64/libreact-native.so
: && ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=x86_64-none-linux-android26 --gcc-toolchain=~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++17 -v -O2 -DNDEBUG -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libreact-native.so -o app/build/intermediates/cxx/Release/231y4r2y/obj/x86_64/libreact-native.so CMakeFiles/react-native.dir/native-lib.cpp.o -Wl,--start-group app/src/main/cpp/lib/x86_64/libvalhalla.a app/src/main/cpp/lib/x86_64/libprotobuf.a app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a app/src/main/cpp/lib/x86_64/libvalhalla-thor.a app/src/main/cpp/lib/x86_64/libvalhalla-meili.a app/src/main/cpp/lib/x86_64/libvalhalla-odin.a app/src/main/cpp/lib/x86_64/libvalhalla-sif.a app/src/main/cpp/lib/x86_64/libvalhalla-skadi.a app/src/main/cpp/lib/x86_64/libvalhalla-tyr.a app/src/main/cpp/lib/x86_64/libvalhalla-midgard.a app/src/main/cpp/lib/x86_64/libvalhalla-proto.a -llog ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/26/liblog.so -landroid -Wl,--end-group app/src/main/cpp/lib/x86_64/libvalhalla-loki.a app/src/main/cpp/lib/x86_64/libvalhalla-tyr.a app/src/main/cpp/lib/x86_64/libvalhalla-loki.a app/src/main/cpp/lib/x86_64/libvalhalla-thor.a app/src/main/cpp/lib/x86_64/libvalhalla-odin.a app/src/main/cpp/lib/x86_64/libvalhalla-proto.a app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a -latomic -lm && :
Android (7019983 based on r365631c3) clang version 9.0.9 (https://android.googlesource.com/toolchain/llvm-project a2a1e703c0edb03ba29944e529ccbf457742737b) (based on LLVM 9.0.9svn)
Target: x86_64-none-linux-android26
Thread model: posix
InstalledDir: ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9.x
Found candidate GCC installation: ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x
Selected GCC installation: ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x
Candidate multilib: .;#m64
Selected multilib: .;#m64
"~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld" --sysroot=~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot -z noexecstack --warn-shared-textrel -z now -z relro --hash-style=gnu --enable-new-dtags --eh-frame-hdr -m elf_x86_64 -shared -o app/build/intermediates/cxx/Release/231y4r2y/obj/x86_64/libreact-native.so ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/26/crtbegin_so.o -L~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/lib/linux/x86_64 -L~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x -L~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/lib/../lib64 -L~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/26 -L~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android -L~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/lib -L~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib --exclude-libs libgcc.a --exclude-libs libgcc_real.a --exclude-libs libatomic.a --build-id --fatal-warnings --no-undefined -soname libreact-native.so CMakeFiles/react-native.dir/native-lib.cpp.o --start-group app/src/main/cpp/lib/x86_64/libvalhalla.a app/src/main/cpp/lib/x86_64/libprotobuf.a app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a app/src/main/cpp/lib/x86_64/libvalhalla-thor.a app/src/main/cpp/lib/x86_64/libvalhalla-meili.a app/src/main/cpp/lib/x86_64/libvalhalla-odin.a app/src/main/cpp/lib/x86_64/libvalhalla-sif.a app/src/main/cpp/lib/x86_64/libvalhalla-skadi.a app/src/main/cpp/lib/x86_64/libvalhalla-tyr.a app/src/main/cpp/lib/x86_64/libvalhalla-midgard.a app/src/main/cpp/lib/x86_64/libvalhalla-proto.a -llog ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/26/liblog.so -landroid --end-group app/src/main/cpp/lib/x86_64/libvalhalla-loki.a app/src/main/cpp/lib/x86_64/libvalhalla-tyr.a app/src/main/cpp/lib/x86_64/libvalhalla-loki.a app/src/main/cpp/lib/x86_64/libvalhalla-thor.a app/src/main/cpp/lib/x86_64/libvalhalla-odin.a app/src/main/cpp/lib/x86_64/libvalhalla-proto.a app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a -latomic -lm -Bstatic -lc++ -Bdynamic -lm -lgcc -ldl -lc -lgcc -ldl ~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/26/crtend_so.o
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::deflate(std::__ndk1::function<int (z_stream_s&)> const&, std::__ndk1::function<void (z_stream_s&)> const&, int, bool): error: undefined reference to 'deflateInit2_'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::deflate(std::__ndk1::function<int (z_stream_s&)> const&, std::__ndk1::function<void (z_stream_s&)> const&, int, bool): error: undefined reference to 'deflate'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::deflate(std::__ndk1::function<int (z_stream_s&)> const&, std::__ndk1::function<void (z_stream_s&)> const&, int, bool): error: undefined reference to 'deflateEnd'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::deflate(std::__ndk1::function<int (z_stream_s&)> const&, std::__ndk1::function<void (z_stream_s&)> const&, int, bool): error: undefined reference to 'deflateEnd'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::deflate(std::__ndk1::function<int (z_stream_s&)> const&, std::__ndk1::function<void (z_stream_s&)> const&, int, bool): error: undefined reference to 'deflateEnd'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::deflate(std::__ndk1::function<int (z_stream_s&)> const&, std::__ndk1::function<void (z_stream_s&)> const&, int, bool): error: undefined reference to 'deflateEnd'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::inflate(std::__ndk1::function<void (z_stream_s&)> const&, std::__ndk1::function<int (z_stream_s&)> const&): error: undefined reference to 'inflateInit2_'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::inflate(std::__ndk1::function<void (z_stream_s&)> const&, std::__ndk1::function<int (z_stream_s&)> const&): error: undefined reference to 'inflate'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::inflate(std::__ndk1::function<void (z_stream_s&)> const&, std::__ndk1::function<int (z_stream_s&)> const&): error: undefined reference to 'inflateEnd'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::inflate(std::__ndk1::function<void (z_stream_s&)> const&, std::__ndk1::function<int (z_stream_s&)> const&): error: undefined reference to 'inflateEnd'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::inflate(std::__ndk1::function<void (z_stream_s&)> const&, std::__ndk1::function<int (z_stream_s&)> const&): error: undefined reference to 'inflateEnd'
app/src/main/cpp/lib/x86_64/baldr/libvalhalla-baldr.a(compression_utils.cc.o):compression_utils.cc:function valhalla::baldr::inflate(std::__ndk1::function<void (z_stream_s&)> const&, std::__ndk1::function<int (z_stream_s&)> const&): error: undefined reference to 'inflateEnd'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
I know it has to with linking dependencies but I don't know how to fix it, I've been trying to fix this for weeks now but with no success.
app/gradle.build
cmake {
arguments "-DCMAKE_BUILD_TYPE=Release"
cppFlags "-std=c++17", "-v"
abiFilters "x86_64"
}
Edit: Update stacktrace and CMakeLists.txt
From your build output it seems that some of the valhalla libraries depend on each other, and those dependencies are not reflected in your CMakeLists.txt. For example, the Tyr library seems to depend at least on the Baldr, Loki, Thor and Odin libraries (as can be seen from the names of the undefined symbols you get). To reflect this dependency you should add something like this to your CMakeLists.txt file:
target_link_libraries(valhalla-tyr PUBLIC
valhalla-baldr
valhalla-loki
valhalla-thor
valhalla-odin
)
If after applying this you get undefined symbols from other libraries you should also add similar dependencies for other Valhalla libraries.
As an effect of this, the linker will be passed a slightly different set of arguments, with some libraries possibly listed more than once or in a different order. This will help the linker find the missing symbols.
Another possible solution is to enclose Valhalla libraries within --start-group/--end-group arguments in your last target_link_libraries statement. This solution would be more compiler-dependent but if this CMakeLists file is only intended to be used for Android this might be fine:
target_link_libraries( react-native
-Wl,--start-group
libvalhalla
valhalla-baldr
# other valhalla libraries
-Wl,--end-group
# ...
)

Library created with debug info when set release flags

This is my shell command:
cmake . \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_TOOLCHAIN_FILE=$toolchain \
-DANDROID_NDK=$ndk_path \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_ABI=$arc_abi \
-DANDROID_PLATFORM=android-21 \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_STL=c++_static
make
and in CMakeLists:
cmake_minimum_required( VERSION 3.5.1 )
project(husky)
set(prelibs "${CMAKE_SOURCE_DIR}/../../../../third_party/libs")
set(third_include "${CMAKE_SOURCE_DIR}/../../../../third_party/include")
set(src_root "${CMAKE_SOURCE_DIR}/../../../../src")
message(STATUS "cur dir:${CMAKE_CURRENT_SOURCE_DIR}")
string(REPLACE "-Oz" "-O3" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE "-Os" "-O3" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread -O3 -Wnon-virtual-dtor -Wno-unused-parameter")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wextra -flto -fuse-ld=gold -Wl")
set( CMAKE_BUILD_TYPE Release )
...
...
add_library(my_test
SHARED
${ALGO_SRC_LIST}
${API_SRC_LIST}
${STAGE_SRC_LIST}
${UTILS_SRC_LIST}
${UTILS_CPU_LIST}
${UTILS_FORMAT_LIST}
${PIPELINE_SRC_LIST}
)
target_link_libraries(my_test
libopencv_imgproc
libopencv_core
libcpufeatures
video
libtbb
libalgo
libprotobuf
${EXTRA_LIBS}
)
Whether I set CMAKE_BUILD_TYPE or not, build library always has debuginfo. What's wrong with it?
update: my target is a dynamic library. when add "set( CMAKE_BUILD_TYPE Release )" in CMakeLists.txt or add "-DCMAKE_BUILD_TYPE=Release" in cmake command, result is always a debug library。

Building Boost Library for Android on OS X Mavericks

I'm having an issue with attempting to build boost library for android. I have the apple command line tools installed and I downloaded boost. I kept getting this error:
In file included from libs/thread/src/pthread/thread.cpp:9:
In file included from ./boost/thread/detail/config.hpp:11:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
./boost/config/posix_features.hpp:18:15: fatal error: 'unistd.h' file not found
# include <unistd.h>
^
1 error generated.
...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/pthread/thread.o...
gcc.compile.c++ bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/pthread/once.o
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -Wno-unused-function --sysroot=/Users/mac/src/android/tc/sysroot -fPIC -O3 -Wextra -Wno-long-long -Wno-variadic-macros -Wunused-function -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_ATOMIC_STATIC_LINK=1 -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/pthread/once.o" "libs/thread/src/pthread/once.cpp"
In file included from libs/thread/src/pthread/once.cpp:6:
In file included from ./boost/thread/detail/config.hpp:11:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
./boost/config/posix_features.hpp:18:15: fatal error: 'unistd.h' file not found
# include <unistd.h>
^
1 error generated.
...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/pthread/once.o...
gcc.compile.c++ bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/future.o
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -Wno-unused-function --sysroot=/Users/mac/src/android/tc/sysroot -fPIC -O3 -Wextra -Wno-long-long -Wno-variadic-macros -Wunused-function -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_ATOMIC_STATIC_LINK=1 -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/future.o" "libs/thread/src/future.cpp"
In file included from libs/thread/src/future.cpp:6:
In file included from ./boost/thread/detail/config.hpp:11:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
./boost/config/posix_features.hpp:18:15: fatal error: 'unistd.h' file not found
# include <unistd.h>
^
1 error generated.
I got the same when building Boost 1.55.0 on Maverick with MacOSX10.7.sdk. So I added -I/usr/include to cflags and cxxflags options in my compile command. It resolved this problem. My full command.
./b2 -d+2 toolset=clang cxxflags="-stdlib=libc++ -isysroot=$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -I/usr/include" cflags="-stdlib=libc++ -isysroot=$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -I/usr/include" --layout=system --build-type=minimal --prefix=$QTDIR link=static runtime-link=static variant=release install

Linker error: undefined reference to `EVP_cast5_ecb'

I'm trying to compile openssl with cast support but I instead get this error:
SharedLibrary : libcrypto.so
./obj/local/armeabi/objs/crypto/evp/c_allc.o: In function `OpenSSL_add_all_ciphers':
~/testandroid/libssl/jni/crypto/evp/c_allc.c:143: undefined reference to `EVP_cast5_ecb'
~/testandroid/libssl/jni/crypto/evp/c_allc.c:144: undefined reference to `EVP_cast5_cfb64'
~/testandroid/libssl/jni/crypto/evp/c_allc.c:145: undefined reference to `EVP_cast5_ofb'
~/testandroid/libssl/jni/crypto/evp/c_allc.c:146: undefined reference to `EVP_cast5_cbc'
./obj/local/armeabi/objs/crypto/evp/e_old.o: In function `EVP_cast5_cfb':
~/testandroid/libssl/jni/crypto/evp/e_old.c:104: undefined reference to `EVP_cast5_cfb64'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libcrypto.so] Error 1
EVP_cast5_ecb and friends are all defined in ~/testandroid/libssl/jni/crypto/evp/evp.h and in ~/testandroid/libssl/jni/include/evp.h
#ifndef OPENSSL_NO_CAST
const EVP_CIPHER *EVP_cast5_ecb(void);
const EVP_CIPHER *EVP_cast5_cbc(void);
const EVP_CIPHER *EVP_cast5_cfb64(void);
# define EVP_cast5_cfb EVP_cast5_cfb64
const EVP_CIPHER *EVP_cast5_ofb(void);
#endif
In crypto/Android.mk
local_src_files := \
evp/c_allc.c \
evp/e_old.c \
# And a whole bunch of other c files
local_c_includes := \
$(APP_PROJECT_PATH) \
$(APP_PROJECT_PATH)/crypto/asn1 \
$(APP_PROJECT_PATH)/crypto/evp \ # evp.h is located here
$(APP_PROJECT_PATH)/include \
$(APP_PROJECT_PATH)/include/openssl # Another evp.h is also located here
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../android-config.mk
ifeq ($(TARGET_ARCH),arm)
LOCAL_NDK_VERSION := 5
LOCAL_SDK_VERSION := 9
# Use the NDK prebuilt libz and libdl.
LOCAL_LDFLAGS += -lz -ldl
else
LOCAL_SHARED_LIBRARIES += libz libdl
endif
LOCAL_SRC_FILES += $(local_src_files)
LOCAL_CFLAGS += $(local_c_flags)
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE:= libcrypto
include $(BUILD_SHARED_LIBRARY)
I'm probably missing something very trivial here, since I'm new to Android and C in general, so be nice :)
EDIT: I saw that there is a Makefile for cast. I'm guessing there is a whole load of linking magic going on at the very bottom of the original Makefile. How would I do something equivalent for Android?
#
# OpenSSL/crypto/cast/Makefile
#
DIR= cast
TOP= ../..
CC= cc
CPP= $(CC) -E
INCLUDES=
CFLAG=-g
MAKEFILE= Makefile
AR= ar r
CAST_ENC=c_enc.o
CFLAGS= $(INCLUDES) $(CFLAG)
ASFLAGS= $(INCLUDES) $(ASFLAG)
AFLAGS= $(ASFLAGS)
GENERAL=Makefile
TEST=casttest.c
APPS=
LIB=$(TOP)/libcrypto.a
LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
SRC= $(LIBSRC)
EXHEADER= cast.h
HEADER= cast_s.h cast_lcl.h $(EXHEADER)
ALL= $(GENERAL) $(SRC) $(HEADER)
top:
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
all: lib
lib: $(LIBOBJ)
$(AR) $(LIB) $(LIBOBJ)
$(RANLIB) $(LIB) || echo Never mind.
#touch lib
cast-586.s: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
$(PERL) asm/cast-586.pl $(PERLASM_SCHEME) $(CLAGS) $(PROCESSOR) > $#
files:
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
links:
#$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
#$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
#$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
install:
#[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
#headerlist="$(EXHEADER)"; for i in $$headerlist ; \
do \
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
done;
tags:
ctags $(SRC)
tests:
lint:
lint -DLINT $(INCLUDES) $(SRC)>fluff
depend:
#[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
dclean:
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
mv -f Makefile.new $(MAKEFILE)
clean:
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
# DO NOT DELETE THIS LINE -- make depend depends on it.
c_cfb64.o: ../../e_os.h ../../include/openssl/cast.h
c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_cfb64.o: c_cfb64.c cast_lcl.h
c_ecb.o: ../../e_os.h ../../include/openssl/cast.h
c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_ecb.o: ../../include/openssl/opensslv.h c_ecb.c cast_lcl.h
c_enc.o: ../../e_os.h ../../include/openssl/cast.h
c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_enc.o: c_enc.c cast_lcl.h
c_ofb64.o: ../../e_os.h ../../include/openssl/cast.h
c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_ofb64.o: c_ofb64.c cast_lcl.h
c_skey.o: ../../e_os.h ../../include/openssl/cast.h
c_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_skey.o: c_skey.c cast_lcl.h cast_s.h

Categories

Resources