Monday, January 23, 2012

simplest cgo program

Have been struggling to make a simple cgo sample to get familiar on how to link c code and go library.

Finally made it working.

package cgo_test


void out() {
printf("Hello world from c\n");
import "C"

func Out() {

package main

import "cgo_test"

func main() {

include ../go/src/


include ../go/src/Make.pkg

main: install main.go
$(GC) main.go
$(LD) -o $@ main.$O

The most annoy error message I got is something like:
gomake main
main.go:6: cannot refer to unexported name cgo_test.out
main.go:6: undefined: cgo_test.out

It seems that GO only export Initcap names by default.

Saturday, January 21, 2012

VirtualBox Scientific Linux Issues and Resolution

* Change the default screen resolution 1024x768
  1. Install VboxAddtions
  2. Define the new resolution with xrandra & cvt
  3. Add the new mode into /etc/gdm/Init/Default to make it permanent
xrandr --newmode "1440x900" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
xrandr --addmode VBOX0 1440x900
xrandr --output VBOX0 --mode 1440x900

* The New IME ibus
For RH5.*, scim is the default IME. Now Ibus takes its position. The problem is that the Ibus is not setup correctly after installation. I've go "No input windows" for all the applications:

  1. Enable the ibus daemon from "System" -> "Preference" -> "Startup Applications", add an entry with command "/usr/bin/ibus-daemon -d"
  2. Add 3 lines into your bash profile (/etc/profile or .bashrc or .bash_profile)
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus