Self-practice for cgo.
use basic C function
cd helloworld-01
go run main.go
call customize C function
cd helloworld-02-func
go run main.go
main.go call C function which call Go function
Go -> C -> Go
cd helloworld-03-gcg
go run main.go
import independent .c
file
cd helloworld-04-c-source
go run main.go
use static link library
cd helloworld-05-static-link-lib
cd helloworld
gcc -c helloworld.c -o helloworld.o
ar -crs libhelloworld.a helloworld.o
cd ..
go run main.go
use dynamic link library
cd helloworld-06-dynamic-link-lib
# build dynamic link
cd src
gcc -shared -o libhelloworld.so helloworld.c
# move .so to lib foldeer
mv libhelloworld.so ../lib
# [in MacOS] set DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=<absolutie_path_of_this_project>/helloworld-06-dynamic-link-lib/lib
# back to helloworld-06-dynamic-link-lib folder
cd ..
go run main.go