编辑 | blame | 历史 | 原始文档

简介

bhshmq 基于共享内存的消息通讯库,支持 请求-应答,发布-订阅 两种通讯方式。
客户端/节点 需要先向管理中心注册成功后才能正常收发消息。

开发环境:

ubuntu 18.04, g++-7.5, cmake, ninja, vscode

依赖库:

boost-1.75.0

准备

下载并解压 boost 库, 编译前需要先修改默认编译选项:打开 tools/build/src/tools/gcc.jam, 找到如下一行:

compile-link-flags <link>shared/<target-os>$(non-windows) : -fPIC ;

在下面增加如下一行:

compile-link-flags <link>static/<target-os>$(non-windows) : -fPIC ;

编译:

	./bootstrap.sh
	./b2 --with-timer --with-test --with-log link=static runtime-link=static threading=multi

安装:

可以直接把代码和库连接到 /usr/local/include 和 /usr/local/lib 
	cd /usr/local/include
	sudo ln <path_to_boost>/boost ./ -s
	cd /usr/local/lib
	sudo ln <path_to_boost>/stage/lib/lib*.a ./ -s

protobuf-3.17.0

准备

下载并解压 protobuf 库.

编译:

	./configure CFLAGS=-fPIC CXXFLAGS="-g -std=c++14 -DNDEBUG -fPIC -ffunction-sections -fdata-sections" LDFLAGS="-fPIC -static-libstdc++"
	make
	sudo make install

bhshmq 编译

	mkdir build; cd build
	cmake -G Ninja -DCMAKE_BUILD_TYPE=RELEASE ..
	ninja