Skip to content

trunkszi/cgo-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#cgo-exmaple

There are five examples of using cgo.

builtin

C code is built in Go program.

usage: cd builtin && go build && ./builtin

c-lib

Using C static library in Go program.

The function add was written in C and built in static library: add.a.

usage: cd c-lib && make && ./c-lib

c-so

Using C shared library in Go program.

The function add was written in C and built in shared library: add.so.

usage: cd c-so && make && ./c-so

go-lib

Calling Go function in C program.

The function add was written in Go and built in static library.

Then called by main.c.

usage: cd go-lib && make && ./go-lib

go-so

Calling go function in c program.

The function add was written in Go and built in shared library.

Then called by main.c.

usage: cd go-so && make && ./go-so

About

examples of using cgo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 46.1%
  • Makefile 26.0%
  • C 18.0%
  • C++ 9.9%