Open Guang1234567 opened 5 years ago
you need to instruct gradle to also link in libiconv
together with libhs
. And you may need to pass -fPIC
to armv7-linux-androideabi-ghc
as well.
@angerman
I build success by instruct gradle to link libiconv
, thanks your help.
The completed demo is here, hope help other one
But I want to build a share lib
by typing :
aarch64-linux-android-ghc -fPIC \
-shared -liconv -lcharset \
-L/Users/XXX/dev_kit/src_code/hs-android-helloworld/app/pre-build-libs/libiconv_prefix/arm64-v8a/lib \
./src/main/hs/Lib.hs \
-o /Users/XXXX/dev_kit/src_code/hs-android-helloworld/app/hs-libs/arm64-v8a/libhs.so
but get compile error :
Linking /Users/lihanguang/dev_kit/src_code/hs-android-helloworld/app/hs-libs/arm64-v8a/libhs.so ...
WRAPPED: clang --target=aarch64-linux-android --sysroot /Users/lihanguang/dev_kit/Android/sdk/ndk-bundle/platforms/android-24/arch-arm64 -isystem /Users/lihanguang/dev_kit/Android/sdk/ndk-bundle/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=24 @/var/folders/x4/9b7hp58x4t54jdslq2mk7_wc0000gn/T/ghc54058_0/ghc_1.rsp
WRAPPED: ld --sysroot /Users/XXX/dev_kit/Android/sdk/ndk-bundle/platforms/android-24/arch-arm64 --sysroot=/Users/XXX/dev_kit/Android/sdk/ndk-bundle/platforms/android-24/arch-arm64 --fix-cortex-a53-843419 --eh-frame-hdr -m aarch64linux -shared -o /Users/XXX/dev_kit/src_code/hs-android-helloworld/app/hs-libs/arm64-v8a/libhs.so /Users/XXX/dev_kit/Android/sdk/ndk-bundle/platforms/android-24/arch-arm64/usr/lib/crtbegin_so.o -L/Users/XXX/dev_kit/src_code/hs-android-helloworld/app/pre-build-libs/libiconv_prefix/arm64-v8a/lib -L/Users/XXX/dev_kit/haskell/ghc-8.4.0.20180109-aarch64-linux-android/lib/../lib/aarch64-linux-android-ghc-8.4.0.20180109/base-4.11.0.0 -L/Users/angerman/Projects/zw3rk/prebuilt/libiconv/aarch64-linux-android/lib -L/Users/XXX/dev_kit/haskell/ghc-8.4.0.20180109-aarch64-linux-android/lib/../lib/aarch64-linux-android-ghc-8.4.0.20180109/integer-simple-0.1.1.1 -L/Users/XXX/dev_kit/haskell/ghc-8.4.0.20180109-aarch64-linux-android/lib/../lib/aarch64-linux-android-ghc-8.4.0.20180109/ghc-prim-0.5.2.0 -L/Users/XXX/dev_kit/haskell/ghc-8.4.0.20180109-aarch64-linux-android/lib/../lib/aarch64-linux-android-ghc-8.4.0.20180109/rts-1.0 -L/Users/XXX/dev_kit/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/6.0.2/lib/linux/aarch64 -L/Users/XXX/dev_kit/Android/sdk/ndk-bundle/platforms/android-24/arch-arm64/usr/lib -z noexecstack --hash-size=31 --reduce-memory-overheads --no-as-needed -lm src/main/hs/Lib.o -Bsymbolic -h libhs.so -lHSbase-4.11.0.0 -lHSinteger-simple-0.1.1.1 -lHSghc-prim-0.5.2.0 -liconv -lgcc -ldl -lc -lgcc -ldl /Users/XXX/dev_kit/Android/sdk/ndk-bundle/platforms/android-24/arch-arm64/usr/lib/crtend_so.o
ld: cannot find -lgcc
ld: cannot find -lgcc
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`aarch64-linux-android-clang' failed in phase `Linker'. (Exit code: 1)
I donot know why has redundant -lgcc -ldl -lc -lgcc -ldl
option argument?
Is sth i missing or the cross-compiler not support build share lib
?
The redundant flags should be no issue to the linker.
ld: cannot find -lgcc
means it's looking for libgcc.a
or libgcc.so
or something similar. You'll need to add a Library Search Path for that lib as well -L/path/to/folder/containing/libgcc/
.
Hello dev:
I download a prebuild cross compiler that base on ghc 8.4.0 for android on OSX. (dowload from http://hackage.mobilehaskell.org/).
Then build the
libhs.a
by typing in termianl:Finally, run this demo by
gradle assembleDebug
, i get a ndk compile error :Could you give me some suggestion? Thanks.