apt直接安装
# zmq protobuf 环境安装
apt-get update
apt-get upgrade
apt-get install vim g++ cmake libprotobuf-dev protobuf-compiler libzmq3-dev -y
源码编译
# protobuf源码编译
cd protobuf-3.20.2/
mkdir build-make
cd build-make
sudo cmake ./ ../cmake/
sudo make install
# 提示 include lib bin的位置, 取出来放到一起
# libzmq源码编译
mkdir build
cd build
cmake ..
make -j8
sudo make install
CMakeLists使用
源码编译与 sudo apt install libprotobuf-dev
使用方法有所不同
# CmakeLists.txt
# lib
link_directories(
/usr/local/lib #add protobuf
)
# target
target_link_libraries(${PROJECT_NAME}_node
protobuf
-lpthread
)
而apt安装的需要这样
# CmakeLists.txt
# target
target_link_libraries(${PROJECT_NAME}_node
-lprotobuf
-lpthread
)