Go mobile bind work with flags

290 views
Skip to first unread message

rogerl...@gmail.com

unread,
May 2, 2016, 10:23:47 PM5/2/16
to golang-nuts
For the past 2 weeks i've been banging my head against the wall trying to learn go.  Not to learn go as a language, but to get a simple go program for my photo printer to work with an android Cordova app.  Here is where i beg for help.  I am a webdeveloper/construction worker and would love someones assistance with this project. 

I just need a way to create java bindings from my project on github...  https://github.com/pbdesign/selphy

As i understand it this is possible with gomobile.  The go program is simple "go run selphy.go image.jpg" would send the image to the printer, it receives it and prints.  It works fine, the problem lies in flags i suppose.  I keep getting this error

gomobile bind --target=android selphy
gomobile: loadExportData failed go install -p=2 -pkgdir=/home/mrlarge/.gvm/pkgsets/go1.6.2/global/pkg/gomobile/pkg_android_arm -tags="" -gcflags=-shared -ldflags=-shared selphy failed: exit status 2
# selphy
/home/mrlarge/.gvm/gos/go1.6.2/pkg/tool/linux_amd64/link: -shared and -buildmode=pie are incompatible

This error is on a fresh install of ubuntu 16.04 LTS, gvm with go1.6.2 .

I've also tried other versions of go1.5.  Same result.

Any help would leave me indebted....

Daniel Skinner

unread,
May 2, 2016, 11:26:54 PM5/2/16
to rogerl...@gmail.com, golang-nuts
You know, I decided to take a look at this and it really threw me for a loop. And then I realized the very first line of selphy.go reads "package main" :)

You just need to declare a package name other than main. For example, try "package selphy" and then gomobile bind will work and produce an aar.

You'll need expose the functionality of whatever your func main does some other way though so you can call it from the android app.

--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Skinner

unread,
May 2, 2016, 11:36:58 PM5/2/16
to rogerl...@gmail.com, golang-nuts
I also went ahead and filed this wrt your situation as well: https://github.com/golang/go/issues/15515
I think the error message could be better.

rogerl...@gmail.com

unread,
May 26, 2016, 3:27:33 PM5/26/16
to golang-nuts, rogerl...@gmail.com
First of all i would like to thank you, after all the torment i put my self through it was as simple as that.  I would actually like your honest opinion about the script as i keep running into other problems e.i. "Unsupported flags DT_FLAGS_1=0x9" and not knowing the language, plus the high level of structure golang uses.  Do you think its reasonable for me to continue in this direction, or find other approaches and or just hire someone.  This project started to build a photo booth for a wedding in a month lol.  And if you think it would be feasible to hire someone, where would i find someone with go mobile experience.

Thanks in advance,
    Roger

Daniel Skinner

unread,
May 27, 2016, 11:06:59 PM5/27/16
to rogerl...@gmail.com, golang-nuts
You can hire me if you like, I technically work as a contractor (email me privately if you like), but first and foremost I'm more curious about the error you're seeing. I have limited experience with C/C++ and when I google "Unsupported flags DT_FLAGS_1" I get some rather curious results regarding linking. You had previously published source for your application, is the above error occurring with your publicly published project? I'd like to see why that's the case if so.

rogerl...@gmail.com

unread,
Jun 6, 2016, 11:53:10 AM6/6/16
to golang-nuts, rogerl...@gmail.com
Thanks for the reply and sorry it takes me so long to reply, currently traveling.  Yes the go file has just changed with the recommendations you said earlier.  Its up at https://github.com/pbdesign/selphy.  The full project is at https://github.com/pbdesign/printproject with a installable apk in the android folder of the com.photobooth project directory.

I've since gotten the project to print by spooling up linux on android and running the go script.  Lol a hack but it works but i'm still interested in why i couldn't get this to work.

If you have any more ideas or need any other files let me know this hurts my head at the moment.


What i got going on in the project is a Cordova project that uses gradle to build.  I created a android plugin that calls the go script in the form of an .aar.  All works with the simple hello world.go .aar.  So i know that everything works.  But adding in the selphyprint.aar it has that error in adb logcat.  So ?.

Thanks Roger
Reply all
Reply to author
Forward
0 new messages