linux protobuf安裝和使用

2021-09-24 02:34:54 字數 2217 閱讀 4768

protobuf的安裝:

解壓後/configure && make && sudo make install  

安裝後路徑位於:/usr/local/bin/protoc

protoc-gen-lua的安裝:

解壓後,cd protoc-gen-lua-master/protobuf

make

make之後報錯,報錯如下:

gcc -o3 -shared -fpic pb.c `/usr/bin/pkg-config --cflags lua5.1` -std=gnu99 `/usr/bin/pkg-config --libs lua5.1` -o pb.so

package lua5.1 was not found in the pkg-config search path.

perhaps you should add the directory containing `lua5.1.pc'

to the pkg_config_path environment variable

no package 'lua5.1' found

package lua5.1 was not found in the pkg-config search path.

perhaps you should add the directory containing `lua5.1.pc'

to the pkg_config_path environment variable

no package 'lua5.1' found

pb.c:440:30: error: array type has incomplete element type

static const struct lual_reg _pb = {

^pb.c:456:30: error: array type has incomplete element type

static const struct lual_reg _c_iostring_m = {

^pb.c: in function 『luaopen_pb』:

pb.c:470:5: warning: implicit declaration of function 『lual_register』 [-wimplicit-function-declaration]

lual_register(l, null, _c_iostring_m);

^make: *** [pb.so] error 1

從錯誤來看,找不到lua5.1.pc,需要設定pkg_config_path這個環境變數,經過搜尋發現,實際是需要lua.pc這個問題,需要建立乙個軟連線,lua5.1.pc指向lua.pc。lua.pc一般位於/usr/lib64/pkgconfig/lua.pc這個目錄。pkg_config_path這個環境變數配置成lua5.1.pc這個檔案存在的目錄。

解決這個問題之後,繼續make出現另外乙個錯誤,如下:

gcc -o3 -shared -fpic pb.c `pkg-config -i/usr/include --cflags lua5.1` -std=gnu99 `pkg-config --libs lua5.1` -o pb.so

-i/usr/include: unknown option

pb.c:440:30: error: array type has incomplete element type

static const struct lual_reg _pb = {

^pb.c:456:30: error: array type has incomplete element type

static const struct lual_reg _c_iostring_m = {

^pb.c: in function 『luaopen_pb』:

pb.c:470:5: warning: implicit declaration of function 『lual_register』 [-wimplicit-function-declaration]

lual_register(l, null, _c_iostring_m);

^make: *** [pb.so] error 1

經搜尋發現,在pb.c檔案中需要增加乙個巨集定義:#define lual_reg lual_reg。這樣就能成功編譯出pbc.so檔案。接下去就可以使用pbc.so檔案。

安裝Docker(yum安裝)

確定你是centos7及以上版本 root 192 desktop cat etc redhat release centos linux release 7.2.1511 core 3.yum安裝gcc相關 yum y install gcc yum y install gcc c 4.解除安裝舊...

安裝 python python安裝

pyenv 多版本管理工具 1.linux安裝pyenv方式 git 安裝 1 安裝git yum install git y 2 安裝python編譯依賴 yum y install gcc make patch gdbm devel openssl devel sqlite devel read...

mysql安裝(安裝包安裝)

2 使用命令列 cmd 進入mysql的bin目錄下,初始化資料庫,執行mysqld initialize console console 表示在控制台輸出,不新增則不展示下面那些資訊 最後一行root localhost 後的hd ed4j s 就是臨時密碼,登入時會使用 注意 1 data目錄要...