in cgo doc i found: “When the Go tool sees that one or more Go files use the special import “C”, it will look for other non-Go files in the directory and compile them as part of the Go package. Any…”
so i moved my c code from go file preamble to an external c file
but when i “go run/build” it doesn’t find the functions in c file
what am I doing wrong? or what I did not understand
thanks in advance
How are you building your project?
“go run main.go” or “go build main.go”, nothing special; it’s a try to use a c library from go (and it works very well inside the preamble), very very simple, very few lines of code
You have to build the whole package, e.g.
go build . for the current directory. If you just say to build
main.go, you’ll only get
ok it worked; thanks a lot
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.