Friday, May 27, 2022

[Golang] Golang with Cgo 動態連結(dynamic linking) 函式庫範例與筆記 in Linux environment

之前曾經動手實作並測試Golang with Cgo 動態連結(dynamic linking) 與 靜態連結(static linking)函式庫範例用在Windows環境,相關內容整理在這篇:

[Golang] Golang with Cgo 動態連結(dynamic linking) 與 靜態連結(static linking)函式庫範例與筆記 in Windows environment

最近看到一篇 "最简单的cgo示例",既簡單且完整的示範了Golang with Cgo 動態連結(dynamic linking) 函式庫範例在Linux環境,個人將其改寫並放到github上: 

https://github.com/teyenliu/linux-cgo-example



使用方式:

$ git clone https://github.com/teyenliu/linux-cgo-example
$ cd linux-cgo-example
$ make buildhello
$ cd testing
# 需要修改Makefile內的: 
# -I/<your_path>/linux-cgo-example/testing/3rd/include 與
# -L /<your_path>/linux-cgo-example/testing/3rd/lib
$ make buildtesting
$ ./testing
This is cgo from Go


No comments: