Build and run go programs directly on Android

polaris · · 1478 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I just released an experimental golang package for the <a href="https://play.google.com/store/apps/details?id=com.termux">Termux Android app</a> (note: Android 5.0+ required).</p> <p>After installing the app, run</p> <pre><code>apt update &amp;&amp; apt install golang </code></pre> <p>to install go version 1.5rc1, which allows building go programs on Android directly. I&#39;ve only verified the package by executing a &#34;hello world&#34;-program, so let me know if there is any issue or if the packaging could be improved!</p> <hr/>**评论:**<br/><br/>BOSS_OF_THE_INTERNET: <pre><p>You can build Android apps in Go. Now you can run Go inside Android apps. Circle of life complete.</p></pre>borring: <pre><p><a href="/u/fornwall">/u/fornwall</a> also added nvim to termux, so you can code go in Android as well.</p></pre>jordic: <pre><p>Cool! I asked for it few days ago... With termux and go i can do a lot of new things on my mobile without rooting it ;)</p></pre>borring: <pre><p>Seems like cgo doesn&#39;t work. Or can I just apt the missing things?</p> <p>NVIM_TUI_ENABLE_TRUE_COLORS=1 nv ht.go $ go run ht.go</p> <h1>runtime/cgo</h1> <p>exec: &#34;arm-linux-androideabi-gcc&#34;: executable file not found in $PATH</p></pre>fornwall: <pre><p>Thanks - will look at it!</p> <p>Does it work if you install the &#39;gcc&#39; package, and make a symlink from arm-linux-androideabi-gcc to gcc in $PREFIX/bin?</p></pre>borring: <pre><p>I get this</p> <p>gcc arm-linux-androideabi-gcc $ cd $ go run ht.go</p> <h1>runtime/cgo</h1> <p>/data/data/com.termux/files/usr/tmp//ccLkp1B1.s: Assembler messages: /data/data/com.termux/files/usr/tmp//ccLkp1B1.s: Warning: end of file in comment; newline inserted</p> <h1>runtime/cgo</h1> <p>/data/data/com.termux/files/usr/bin/ld: cannot find -lpthread collect2: error: ld returned 1 exit status</p> <p>If you want to know how to easily reproduce this, just import the net/http package</p></pre>fornwall: <pre><p>Thanks for the detailed error description!</p> <p>I&#39;ve updated both the gcc package (to version 4.9.3-2) to keep the arm-linux-androideabi-gcc symlinks, so that is no longer necessary.</p> <p>The golang package was updated to 1.5rc1-1, which fixes usage of e.g. net/http, and some other issues. Unfortunately, building go correctly on android now causes warnings along the line</p> <pre><code>XXX has text relocations. This is wasting memory and prevents security hardening. Please fix. </code></pre> <p>both when running go itself and go-compiled programs. However, there is not much to do about that (except piping/grepping away that error message) until <a href="https://github.com/golang/go/issues/9210" rel="nofollow">https://github.com/golang/go/issues/9210</a> is fixed!</p> <p>Do a</p> <pre><code>apt update &amp;&amp; apt upgrade </code></pre> <p>to get the above fixes.</p></pre>borring: <pre><p>Well I&#39;ll be.. the http package works! You&#39;re the man.</p></pre>google_you: <pre><pre><code>apt install nodejs apt install docker apt install mongodb npm install express npm start </code></pre> <p>now my phone is web scale</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1478 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传