Build go c-shared library contain c function from c source code - CGO

Hiii guys…

i want to build go c-shared library which contain c function from c source code… is cgo can achieve that???


(I’m not sure I understand the question, and am assuming that you want to use cgo to access a library written in C.)

See the documentation on cgo in the second code example


// #cgo amd64 386 CFLAGS: -DX86=1
// #cgo LDFLAGS: -lpng
// #include <png.h>
import "C"

This shows how to specify LDFLAGS to include a C language library in the build.

thanks jayts…
so this the story,.
i can access library written by go from C and vice versa. but what i want to build is c-shared library from go language (using -buildmode=c-shared)… but the problem is, in my go’s source code im using c function from my C application (which main’s application).
so the point is in my C app i have my “main” function which i want to export to go’s source, and i have to compile my go source to c-shared library (*.so) and im using it in my C application which exported c’s function to Go. can i achieve that?
why i want to build application like that, because i want to another people contribute using Go rather than C language.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.