克隆open62541源码

1
git clone -b v1.0.6 https://github.com/open62541/open62541.git

编译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 进入源码目录
cd open62541/

# 拉取子模块,当编译使能某些特殊功能时就需要,如自定义namespace等
git submodule update --init --recursive --progress

# 创建编译目录并且进入
mkdir build/ && cd build

# 配置编译选项,-DBUILD_SHARED_LIBS=ON 表示生成动态库,-DCMAKE_INSTALL_PREFIX=/usr表示安装路径为/usr
cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr

# 开始编译
make VERBOSE=1

安装与卸载

1
2
3
4
5
# 安装
sudo make install

# 卸载
sudo xargs rm < install_manifest.txt