linux下安裝protobuf及cmake編譯

2022-08-23 15:51:11 字數 1668 閱讀 3308

一.protobuf 安裝

protobuf版本:2.6.1

解壓之後進入目錄

修改autogen.sh

echo "google test not present.  fetching gtest-1.5.0 from the web..."

curl | tar jx

mv gtest-1.5.0 gtest

autogen.sh內的上述內容修改為

wget 

tar xzvf release-1.5.0.tar.gz

mv googletest-release-1.5.0 gtest

然後執行autogen.sh

./autogen.sh

目錄中就會生成出.configure檔案

接著執行

./configure

make

make check

make install

設定環境變數

sudo vi /etc/profile

export path=$path:/usr/local/bin

export pkg_config_path=/usr/local/lib/pkgconfig

cd ~

vi .profile

export path=$path:/usr/local/bin

export pkg_config_path=/usr/local/lib/pkgconfig

配置動態鏈結庫路徑

sudo vi /etc/ld.so.conf

include /usr/local/lib

sudo ldconfig
二.編寫cmakelists

cmake_minimum_required (version 2.8)

project (demo1)

set(src_list test1.cpp)

# find required protobuf package

find_package(protobuf required)

if(protobuf_found)

message(status "protobuf library found")

else()

message(fatal_error "protobuf library is needed but cant be found")

endif()

include_directories($)

include_directories($)

protobuf_generate_cpp(proto_srcs proto_hdrs test1.proto)

add_executable(demo1 $ $ $)

target_link_libraries(demo1 $)

#add_executable(demo test1.cpp)

如果你覺得對你有用請付款

Mac下Go安裝配置並使用Protobuf

首先使用home brew安裝protobuf brew install protobuf 安裝好之後,檢視是否安裝成功 protoc version 如果成功會有如下類似的版本號顯示 libprotoc 3.1.0 這表明我安裝成功,並且版本號是3.1.0。接著安裝protobuf的golang外...

Linux下Redis下安裝

redis安裝 檢查是否安裝redis ps ef grep redis2.檢查gcc服務是否安裝成功 rpm qa grep gcc注 安裝成功則顯示 mkdir redis5.解壓redis安裝包 tar zxvf redis 2.8.17 tar.gz c usr local redis 解壓...

Linux下安裝安裝arm linux gcc

1 tar指令解壓對應壓縮包到指定目錄,如arm linux gcc 4.3.2.tar.bz2壓縮包,sudo tar xvjf arm linux gcc 4.3.2.tar.bz2 c tar壓縮解壓縮 c 建立打包檔案,可搭配 v來觀察過程中被打包的檔名 filename t 檢視打包檔案的...