I build a lib.a static library.then compile main object,but I link the main.o,found some trouble:
main…inittask: relocation target lib…inittask not defined
source file:
src/lib/greet.go
package lib
import “fmt”
func Greet(word string){
fmt.Print(word);
}
src/main/main.go
package main
import (
“lib”
)
func main(){
lib.Greet(“Okay”);
}
command step:
1.go build -o lib.a src/lib/greet.go //if here using go build -o lib.a lib (package),it goes right.Why???
2.go tool compile -I . src/main/main.go
3.go tool link -L .main.o
main…inittask: relocation target lib…inittask not defined
It goes wrong. Why can’t build with source files?