golang 1.4 编译android toolchain的方法

其他平台及架构的toolchain编译我在之前的文章已经简单总结过,其实android的toolchain和之前的toolchain生成非常类似,需要注意以下2点:

1、要通过ndk生成standalone的"ndk-gcc"

2、使用CC_FOR_TARGET=<ndk-gcc>/bin/arm-linux-androideabi-gcc

那么let's go

1、下载NDK,https://developer.android.com/tools/sdk/ndk/index.html

2、通过NDK自带的脚本生成standalone toolchain

<ndk-root>/build/tools/make-standalone-toolchain.sh --platform=android-9 \
    --install-dir=<ndk-gcc> --arch=arm

3、使用standalone toolchain编译golang

进入到<GOROOT>/src

CC_FOR_TARGET=<ndk-gcc>/bin/arm-linux-androideabi-gcc GOOS=android \
    GOARCH=arm GOARM=7 CGO_ENABLED=1 ./make.bash

运行完毕没有错误的话即可生成android的toolchain了

4、使用生成的android toolchain尝试编译一个.so

CC=<ndk-gcc>/bin/arm-linux-androideabi-gcc GOOS=android GOARCH=arm \
    GOARM=7 CGO_ENABLED=1 go build -ldflags="-shared"

使用file命令 file <outputfile>,检查一下生成的文件,格式是否正确

ELF 32-bit LSB  shared object, ARM, EABI5 version 1 (SYSV), dynamically
linked (uses shared libs), not stripped

Shrink VMWare Virtual Disks formatted with ext4[转]

http://www.insomnihack.com/?p=387

If you’re running a Linux distribution under VMWare that uses disks formatted with ext4 (as Ubuntu does by default), you may have had some problems shrinking the resulting virtual disks files your VM uses. This is because ext4 is a journaling file system. It protects your file system in case of a system crash or power failure.

Unfortunately, the current version of VMWare’s tools (I’m using Workstation 7.1 currently) hasn’t been updated to completely handle journaling file systems like ext4. Your disk won’t appear on the shrink tab of vmware-toolbox or be listed when using vmware-toolbox-cmd. This can be frustrating when your virtual disk grows to several gigabytes large than the actual data you’re using under Linux.

However, the good news is that you can reclaim the unused space with a little preliminary work inside your guest OS. First, execute the following commands from within the Linux guest.

$ sudo apt-get clean$ sudo dd if=/dev/zero of=/0bits bs=20M $ sudo rm /0bits 

This will manually clear unused space. Note that the first call to apt-get is not required, and only applicable if you’re running a distribution that uses Debian’s advanced packaging tool for package management.

After you’ve executed these commands, shutdown your VM and use vmware-vdiskmanager to shrink the virtual drive file.

cd "C:Program FilesVMwareVMware Workstation"vmware-vdiskmanager -k pathtoyourVirtualDisk.vmdk You should see a noticeable reduction in file size after this. I have also discovered two things:
(1) for ‘dd’, it’s probably better to mention that you feed the partition size as the ‘bs’ parameter… so one will dd until ‘No space left’.
(2) for swap partition, can do so:
(Assuming that your swap partition is at /dev/sda6)
(Make sure you have enough free memory first)
$ sudo swapoff -a
$ dd if=/dev/zero of=/dev/sda6 bs=20971520 # Just fill up the space
$ sudo swapon -a


ubuntu 9.10 karmic 资源列表

# 网易的源
deb http://mirrors.163.com/ubuntu/ karmic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ karmic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ karmic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ karmic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ karmic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ karmic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ karmic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ karmic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ karmic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ karmic-backports main restricted universe multiverse

# 江苏双线的源
deb http://mirror.lupaworld.com/ubuntu karmic main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu karmic-security main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu karmic-updates main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu karmic-backports main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu/ubuntu-cn karmic main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu/ karmic-proposed main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu karmic main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu karmic-security main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu karmic-updates main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu karmic-backports main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu/ karmic-proposed main restricted universe multiverse

# 台湾的源
deb http://tw.archive.ubuntu.com/ubuntu/ karmic main universe restricted multiverse
deb http://tw.archive.ubuntu.com/ubuntu/ karmic-updates universe main multiverse restricted
deb http://tw.archive.ubuntu.com/ubuntu/ karmic-proposed universe main multiverse restricted
deb http://tw.archive.ubuntu.com/ubuntu/ karmic-security universe main multiverse restricted
deb http://tw.archive.ubuntu.com/ubuntu/ karmic-backports main multiverse restricted universe
deb-src http://tw.archive.ubuntu.com/ubuntu/ karmic main universe restricted multiverse
deb-src http://tw.archive.ubuntu.com/ubuntu/ karmic-security universe main multiverse restricted
deb-src http://tw.archive.ubuntu.com/ubuntu/ karmic-updates universe main multiverse restricted
deb-src http://tw.archive.ubuntu.com/ubuntu/ karmic-proposed universe main multiverse restricted
deb-src http://tw.archive.ubuntu.com/ubuntu/ karmic-backports universe main multiverse restricted

deb http://ubuntu.srt.cn/ubuntu/ karmic main restricted universe multiverse
deb http://ubuntu.srt.cn/ubuntu/ karmic-security main restricted universe multiverse
deb http://ubuntu.srt.cn/ubuntu/ karmic-updates main restricted universe multiverse
deb http://ubuntu.srt.cn/ubuntu/ karmic-proposed main restricted universe multiverse
deb http://ubuntu.srt.cn/ubuntu/ karmic-backports main restricted universe multiverse
deb-src http://ubuntu.srt.cn/ubuntu/ karmic main restricted universe multiverse
deb-src http://ubuntu.srt.cn/ubuntu/ karmic-security main restricted universe multiverse
deb-src http://ubuntu.srt.cn/ubuntu/ karmic-updates main restricted universe multiverse
deb-src http://ubuntu.srt.cn/ubuntu/ karmic-proposed main restricted universe multiverse
deb-src http://ubuntu.srt.cn/ubuntu/ karmic-backports main restricted universe multiverse

# 北京交通大学的源
deb http://mirror.bjtu.edu.cn/ubuntu/ karmic main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ karmic-backports main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ karmic-proposed main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ karmic-security main multiverse restricted universe
deb http://mirror.bjtu.edu.cn/ubuntu/ karmic-updates main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ karmic main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ karmic-backports main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ karmic-proposed main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ karmic-security main multiverse restricted universe
deb-src http://mirror.bjtu.edu.cn/ubuntu/ karmic-updates main multiverse restricted universe

# 下面是自带的源
#deb cdrom:[Ubuntu 9.10 _Karmic Koala_ - Beta i386 (20090930)]/ karmic main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://cn.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ karmic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ karmic-updates main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ karmic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ karmic universe
deb http://cn.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ karmic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ karmic multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ karmic multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ karmic-updates multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ karmic-updates multiverse

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://cn.archive.ubuntu.com/ubuntu/ karmic-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ karmic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu karmic partner
# deb-src http://archive.canonical.com/ubuntu karmic partner

deb http://security.ubuntu.com/ubuntu karmic-security main restricted
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted
deb http://security.ubuntu.com/ubuntu karmic-security universe
deb-src http://security.ubuntu.com/ubuntu karmic-security universe
deb http://security.ubuntu.com/ubuntu karmic-security multiverse
deb-src http://security.ubuntu.com/ubuntu karmic-security multiverse


VM中Ubuntu的Vmware-Tools的安装方法

VMware Tools何许物也?它是VMware提供的一套很贴心的程序,用于解决虚拟机的分辨率问题(我们前面有提过)、改善鼠标的性能(还记得我们前面不断的用 鼠标单击和Ctrl+Alt在虚拟与现实间切换的费劲场景吗?),并且能将虚拟机的剪贴板内容直接粘贴到宿主机中。当然,不安装VMware Tools也不会带来什么灾难,只不过从用户体验方面考虑,装上VMware Tools会给你对虚拟机的操作带来尽可能多的方便。

VMware Tools必须在虚拟机已经开启且已安装操作系统的前提下才能安装。如果你注意过VMware Workstation的安装目录,会发现一些命名为windows.iso、linux.iso、freebsd.iso、solaris.iso的光 盘镜像,这些就是VMware Tools在各种操作系统下的安装文件。VMware Tools就是通过光盘镜像的方式加载到相对应操作系统下来运行安装的。

闲话少叙,点击VMware菜单的 ——虚拟机——安装VMware Tools,在弹出的对话框中选择“安装”。这时,在Ubuntu下会自动加载Linux版的VMware Tools的安装光盘镜像。你会看到虚拟机的桌面上出现了一个名为VMware Tools的光盘图标,并且被自动打开。其中包括VMwareTools-5.3.3-34685-i386.rpm和VMwareTools- 5.3.3-34685.tar.gz两个文件。

.rpm文件是给Red Hat准备的,我们只需要.tar.gz的那个。

点击Ubuntu桌面左上角的Applications——附件——终端,会弹出一个貌似Windows记事本的程序,这就是大名鼎鼎的“终端”。它在Ubuntu中的角色类似Windows里的MS DOS或命令提示符,我们以后会经常性的同它打交道。

在终端界面中依次运行(运行,就是在“$”提示符后面输入一段命令,回车之)如下命令($是自带的,不用专门输入了)——

$ tar zxf /media/cdrom/VMwareTools-5.3.3-34685.tar.gz(回车后系统会把那个.tar.gz文件解压缩)

$ cd vmware-tools-distrib(回车后目录将转换到解压缩后的那个文件夹)

$ sudo ./vmware-install.pl(回车后会提示输入你的密码,表明你将以更高级权限执行一个动作——安装软件;再次回车后安装开始)

经过一番确认回车后(相当于在Windows里安装软件时所填答的诸多对话框,我们这里均采用缺省设置),直到最后出现“Enjoy——the VMware team”的字样后,VMwareTools终于安装完成了。

如 果你使用的是VMware Workstation 6.0.0,现在你应该已经能看到VMware Tools安装后的效果了: 鼠标再也不需要用Ctrl+Alt切换于虚拟与现实之间,一切过渡得那么自然;虚拟机的分辨率也能依窗口的大小来自动适应,一切显得那样和谐。但我们这里 使用的是VMware Workstation 5.5.3,所以暂时你还看不到什么,让我们来做一下最后的设置吧。

在VMware Workstation 5.5.3里,Ubuntu下的VMware Tools安装之后是要靠手动执行/usr/bin/vmware-toolbox才能显示出效果的。你可以通过在终端中输入如下命令来运行它:

$ /usr/bin/vmware-toolbox

但 如果你嫌麻烦,我们就需要让vmware-toolbox实现开机自动运行。点击Ubuntu菜单:System——首选项——会话—— Startup Programs,Add一个Name叫“vmware-toolbox”,Command是“/usr/bin/vmware-toolbox”的启动 程序。这样每次开机后就能自动运行VMware Tools了。重启Ubuntu看看效果吧!(注意:vmware-toolbox并不是在后台隐藏运行的,启动后不要关闭)

VMware Tools固然是个好东西,但也有副作用,比如说:虚拟机中的鼠标的滚轮不好使了。我们这样解决这个问题,还是打开终端,输入:

$ sudo gedit /etc/X11/xorg.conf

这个命令使系统以root权限打开鼠标配置文件/etc/X11/xorg.conf。把文件中的

Option “Protocol” “ps/2”

改成

Option “Protocol” “IMPS/2”

重启Ubuntu搞定。


Gedit中文乱码

缺省配置下,用 Ubuntu 的文本编辑器(gedit)打开 GB18030/GBK/GB2312 等类型的中文编码文本文件时,将会出现乱码。

出现这种情况的原因是,gedit 使用一个编码匹配列表,只有在这个列表中的编码才会进行匹配,不在这个列表中的编码将显示为乱码。您要做的就是将 GB18030 加入这个匹配列表。

  • 命令行方式,适用于所有 Ubuntu 用户。

复制以下命令到终端中,然后回车即可:

gconftool-2 --set --type=list --list-type=string /apps/gedit-2/preferences/encodings/auto_detected "[UTF-8,CURRENT,GB18030,BIG5-HKSCS,UTF-16]"

  • 图形化方式,适用于 Ubuntu 用户,而不适用于 KUbuntu/XUbuntu 用户。

您可以遵循以下步骤,使您的 gedit 正确显示中文编码文件。

  1. 按下 Alt-F2,打开“运行应用程序”对话框。
  2. 在文本框中键入“gconf-edit”,并按下回车键,打开“配置编辑器”。
  3. 展开左边的树节点,找到 /apps/gedit-2/preferences/encodings 节点并单击它。
  4. 双击右边的 auto_detected 键,打开“编辑键”对话框。
  5. 单击列表右边的“添加”按钮,输入“GB18030”,单击确定按钮。
  6. 列表的最底部新增加了一个“GB18030”。单击选中它,并单击右边的 “向上” 按钮直到 “GB18030” 位于列表的顶部为止。
  7. 单击确定按钮,关闭配置编辑器。

现在,您的 gedit 应该能够顺利打开 GB18030 编码的文本文件了。

http://wiki.ubuntu.org.cn/Gedit%E4%B8%AD%E6%96%87%E4%B9%B1%E7%A0%81