On Monday, December 5, 2016 at 7:44:23 AM UTC+1, andrey mirtchovski wrote:
>
> I'm having issues with the latest gomobile + reverse java bindings. I 
> have a piece of code that linked with a C library via CGO. Previously 
> (around 6 months ago) everything appeared file: cross compile library 
> with NDK toolchain (gcc), link against go code with cgo, run "gomobile 
> bind -target=android" and everything worked. 
>
> now it appears gomobile has switched to targeting arm64 with clang. I 
> tried compiling my code against 32-bit gcc, 32-bit clang, and 64-bit 
> clang. even though i can create a successful 32-bit arm binary with 
> the standard Go tools, I am unable to create one with gomobile. here's 
> an example of the 32-bit library I'm using (i've also compiled it 
> static): 
>
> /opt/arm-linux-androideabi/sysroot/usr/lib/mylibrary.so: ELF 32-bit 
> LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses 
> shared libs), not stripped 
>
> gradle build however invokes gomobile bind thusly (major parts of the 
> classpaths stripped): 
>
>
> --------8<---------------- 
> /.../gomobile bind -i -classpath 
> /.../android/android/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.2.1/jars/classes.jar:[...]:/.../android/android/build/intermediates/classes/debug
>  
>
> -o 
> /var/folders/sp/06p28g2d0vs7gd2vhf26wl9m0000gn/T/gobind-2223404674934856774.aar
>  
>
> -target android -bootclasspath 
> /.../sdk/platforms/android-24/android.jar -x my/project 
>
> gomobile then issues this command and receives the following error: 
>
> /Users/aam/pkg/gomobile/android-ndk-r12b/arm64/bin/aarch64-linux-android-clang
>  
>
> -I . -fPIC -pthread -fno-caret-diagnostics -Qunused-arguments 
> -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build 
> -gno-record-gcc-switches -o $WORK/my/project/_obj/_cgo_.o ...-target 
> aarch64-none-linux-android --sysroot 
> /.../pkg/gomobile/android-ndk-r12b/arm64/sysroot 
> /opt/arm-linux-androideabi/sysroot/usr/lib/mylibrary.a  -lm -lz -pie 
>
> # my/project 
>
> /opt/arm-linux-androideabi/sysroot/usr/lib/mylibrary.a: error adding 
> symbols: File in wrong format 
>
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation) 
> --------8<---------------- 
>
> again, this works when using GOOS=arm GOARCH=android CGO_ENABLED=1 go 
> build... also, the reverse example works fine with this setup, but 
> that doesn't attempt any cgo tomfoolery. 
>
> TL;DR: i'm unable to figure out a way to force 32-bit gomobile 
> compilation, especially while staring from outside the "gradle build" 
> wall. 
>


The gradle plugin supports the GOARCH settings which contains a list of the 
architectures you want to include. Use it in your gobind {...} section of 
your build.gradle, along with your "pkg" setting:

apply plugin: "org.golang.mobile.bind"

gobind {
        pkg = "...golang.org/x/mobile/example/bind/hello"

        GOARCH = "arm"
}


 - elias

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to