Hi all,
I am tring to install gccgo on ubuntu 12.04. I succeed to build gcc-4.7.1 with adding go to the --enable-languages like --enable-languages=c,c++,go. Then I get gccgo command in the bin folder of gcc4.7.1. I try to use gccgo -c test.go to build the following code:
// #include <stdio.h>
// #include <stdlib.h>
import "C"
import "unsafe"
func Print(s string) {
cs := C.CString(s)
C.fputs(cs, (*C.FILE)(C.stdout))
C.free(unsafe.Pointer(cs))
}
func main(){
Print("hello googc\n")
}
However, I got the following errors:
testc.go:5:9: error: import file ‘C’ not found
testc.go:9:11: error: reference to undefined name ‘C’
testc.go:10:5: error: reference to undefined name ‘C’
testc.go:10:19: error: reference to undefined name ‘C’
testc.go:10:27: error: reference to undefined name ‘C’
testc.go:11:5: error: reference to undefined name ‘C
Since according to my understanding, after I build the gcc-4.7.1 with enabling go, I don't need to do the followings. Am I right? Thanks all.
svn checkout svn://gcc.gnu.org/svn/gcc/branches/gccgo gccgo
mkdir objdir
cd objdir
../gccgo/configure --prefix=/opt/gccgo --enable-languages=c,c++,go --with-ld=/opt/gold/bin/ld
make
make install