LoRaServer 筆記 1 3 原始碼編譯

2021-09-23 08:04:42 字數 1982 閱讀 3919

end本篇筆記介紹如何進行幾個元件的原始碼編譯,對實際編譯過程中的一些問題也做了記錄。

小能手最近在學習 lora server 專案,應該是最有影響力的 lorawan 伺服器開源專案。它元件豐富,**可讀性強,是個很好的學習資料。更多學習筆記,可點此檢視。

整個開源專案還是用 go 編譯,因此需要安裝基礎的 go 環境。

另外整個編譯過程絕對還是會出現包被牆的情況,2023年了,go 1.11 有個 moudule 可以很方便的處理這些情況。大家可以處理下 go.mod 的檔案,具體在我另一篇筆記中有記錄,the things network lorawan stack v3 學習筆記 1.2 原始碼編譯。

git clone 

cd lora-gateway-bridge/

make dev-requirements

make build

./build/lora-gateway-bridge configfile > lora-gateway-bridge.toml
git clone 

cd loraserver/

make dev-requirements

make build

我們在 make build 時可能會遇到 缺少 go-bindata 的問題:

# make build

generating static files

internal/migrations/migrations.go:1: running "go-bindata"

: exec: "go-bindata"

: executable file not found in

$path

make: *** [statics] error 1

go get -u github.com/jteeuwen/go-bindata/...
安裝完了之後可能會找不到go-bindata,提示錯誤:「-bash: /usr/bin/go-bindata: no such file or directory」。原因在於由於沒有定義gobin目錄,它會自動安裝到gopath\bin目錄下。去那裡找找。

找到之後,在path裡面追加go-bindata的路徑。

#通過命令列加入gobin的path

export path=

$path

:$gopath/bin

as 需要 node.js 和 go protocol buffer。

make dev-requirements ui-requirements

make clean

make build

如果調整了 .proto 檔案,那就需要 make api 處理下,否則可以跳過這一步。當前的 api 的目錄下

make api 時遇到了問題,沒有找到 protoc 命令。

# make api

generating api code from .proto files

gen.sh: line 10: protoc: command not found

gen.sh: line 28: protoc: command not found

gen.sh: line 46: protoc: command not found

安裝之:

protoc_zip=protoc-3.7.1-linux-x86_64.zip

curl -ol

sudo unzip -o $protoc_zip -d /usr/local bin/protoc

rm -f $protoc_zip

1 3 樹莓派軟體源及系統源設定

一 軟體源設定 sudonano etc apt sources.list 2 刪除原檔案所有內容,buster系統用以下內容取代 注 末尾的raspbian重複兩次是必須的。因為raspbian的倉庫中除了apt軟體源還包含其他 apt軟體源不在倉庫的根目錄,而在raspbian 子目錄下。str...

JDK13 HashMap resize原始碼解析

resize是重新雜湊,所以要在現在容量和閾值的基礎上獲取新的容量和閾值,函式首先進行了變數定義 final hashmap.node resize else if newcap oldcap 1 maximum capacity oldcap default initial capacity de...

Effective C 學習筆記 (13)

由於在寫 時很多時候需要用到資源,比如new乙個物件之類的,這樣一來資源的申請和釋放需要程式設計師自己完成,對 的邏輯需要謹慎設計,才能保證資源不會洩漏。其實這類似的程式設計風格,在之前寫c的時候也有編碼規範來規定資源的釋放,比如do while的運用啊,goto exit0之類的方法,但是對於c ...