Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: fail to build reverse bind if dependencies on CGO/external lib #19552

Closed
dolanor opened this issue Mar 14, 2017 · 5 comments
Closed

Comments

@dolanor
Copy link

dolanor commented Mar 14, 2017

What version of Go are you using (go version)?

go version go1.8 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dolanor/.local/gopath/"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build333024791=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

I tried to compile some project for android with the reverse binding, but they were depending on some C library. The library existed on the host, but the compilation failed for android.
The idea is to compile some gRPC client for android in full Go.

What did you expect to see?

A successful build

What did you see instead?

Output from ./gradlew in golab-2017-training

:gomobileDebug
/home/dolanor/repo/golab-2017-training/bin/gomobile: loadExportData failed go install -pkgdir=/home/dolanor/repo/golab-2017-training/pkg/gomobile/pkg_android_arm -gcflags=-shared -ldflags=-shared gorev failed: exit status 2
# gorev/vendor/github.com/miekg/pkcs11
../src/gorev/vendor/github.com/miekg/pkcs11/pkcs11.go:29:10: fatal error: 'ltdl.h' file not found
#include <ltdl.h>
         ^
1 error generated.

ping @eliasnaur since the reverse project I'm basing my work on is from him :)

@bradfitz bradfitz changed the title go/mobile fail to build reverse bind if dependencies on CGO/external lib x/mobile: fail to build reverse bind if dependencies on CGO/external lib Mar 21, 2017
@gopherbot gopherbot added this to the Unreleased milestone Mar 21, 2017
@bradfitz
Copy link
Contributor

/cc @eliasnaur

@eliasnaur
Copy link
Contributor

This doesn't seem to be related to the reverse binding machinery. Running go get github.com/miekg/pkcs11 on my Fedora 25 installation fails as well:

$ go get github.com/miekg/pkcs11
# github.com/miekg/pkcs11
../dev/go/src/github.com/miekg/pkcs11/pkcs11.go:29:18: fatal error: ltdl.h: No such file or directory
 #include <ltdl.h>
                  ^
compilation terminated.

I'm not even sure ltdl.h exists in the NDK.

@dolanor
Copy link
Author

dolanor commented Apr 3, 2017

You're right. I guess I didn't express myself enough (and maybe I don't know where to ask this question, I tried the gomobile slack already). Is it possible to add an external library to a project with gomobile or to the SDK?

@eliasnaur
Copy link
Contributor

I don't see why not, but it's not something I've done myself, and there might be issues I don't know about. Is there a specific library you have in mind? It's much easier to start from a specific build error or crash.

Also, you should probably ask on gomobile-nuts to get a larger audience and to help others in the same situation. Feel free to CC me so I don't miss your post.

@dolanor
Copy link
Author

dolanor commented Apr 4, 2017

The library I'm thinking about is the ltdl library that is needed by the https://github.com/miekg/pkcs11 go package.
I need it because I wanted to contact an hyperledger fabric node from a mobile. And the auth/PKI package from hyperledger depends on the pkcs11 go package.

I will post on go-nuts I think. Thank you very much!

@dolanor dolanor closed this as completed Apr 4, 2017
@golang golang locked and limited conversation to collaborators Apr 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants