文章目录
- [1. 摘要](#1. 摘要)
- [2. 安装、编译](#2. 安装、编译)
-
- [2.1 开发环境说明](#2.1 开发环境说明)
- [2.2 安装依赖](#2.2 安装依赖)
- [2.3 获取代码](#2.3 获取代码)
- [2.4 编译代码](#2.4 编译代码)
- [2.5 安装](#2.5 安装)
- [3. 测试验证](#3. 测试验证)
- 参考
1. 摘要
本文主要描述 vsomeip 的安装、编译与运行步骤。下载源码,安装必要依赖,如Boost和CMake。通过CMake配置编译 vsomeip 库,确保环境配置正确。运行 hello_world 示例验证安装,注意配置环境变量与日志输出。一步步引导,助您快速上手VSOMEIP通信框架。如果您对智驾中间件感兴趣,请持续关注!
2. 安装、编译
2.1 开发环境说明
博主的开发环境是Windows 11,安装WSL2,Linux子系统,版本信息如下:
2.2 安装依赖
bash
sudo apt-get install libboost-system-dev libboost-thread-dev libboost-log-dev
bash
sudo apt-get install asciidoc source-highlight doxygen graphviz
bash
sudo apt-get install gcc g++ make
2.3 获取代码
bash
git clone git@gitee.com:mirrors/vsomeip.git
代码结构如下:
2.4 编译代码
bash
mkdir build
cd build
cmake ..
make
2.5 安装
bash
sudo make install
安装过程输出:
bash
Consolidate compiler generated dependencies of target vsomeip3
[ 67%] Built target vsomeip3
Consolidate compiler generated dependencies of target vsomeip3-cfg
[ 69%] Built target vsomeip3-cfg
Consolidate compiler generated dependencies of target vsomeip3-sd
[ 84%] Built target vsomeip3-sd
Consolidate compiler generated dependencies of target vsomeip3-e2e
[ 98%] Built target vsomeip3-e2e
Consolidate compiler generated dependencies of target routingmanagerd
[100%] Built target routingmanagerd
Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/application.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/constants.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/defines.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/enumeration_types.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/error.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/export.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/function_types.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/handler.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/internal/deserializable.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/internal/serializable.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/message.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/message_base.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/payload.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/plugin.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/plugins/application_plugin.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/plugins/pre_configuration_plugin.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/primitive_types.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/runtime.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/trace.hpp
-- Installing: /usr/local/include/vsomeip/../compat/vsomeip/vsomeip.hpp
-- Installing: /usr/local/include/vsomeip/application.hpp
-- Installing: /usr/local/include/vsomeip/constants.hpp
-- Installing: /usr/local/include/vsomeip/defines.hpp
-- Installing: /usr/local/include/vsomeip/deprecated.hpp
-- Installing: /usr/local/include/vsomeip/enumeration_types.hpp
-- Installing: /usr/local/include/vsomeip/error.hpp
-- Installing: /usr/local/include/vsomeip/export.hpp
-- Installing: /usr/local/include/vsomeip/function_types.hpp
-- Installing: /usr/local/include/vsomeip/handler.hpp
-- Installing: /usr/local/include/vsomeip/internal/deserializable.hpp
-- Installing: /usr/local/include/vsomeip/internal/logger.hpp
-- Installing: /usr/local/include/vsomeip/internal/policy_manager.hpp
-- Installing: /usr/local/include/vsomeip/internal/serializable.hpp
-- Installing: /usr/local/include/vsomeip/message.hpp
-- Installing: /usr/local/include/vsomeip/message_base.hpp
-- Installing: /usr/local/include/vsomeip/payload.hpp
-- Installing: /usr/local/include/vsomeip/plugin.hpp
-- Installing: /usr/local/include/vsomeip/plugins/application_plugin.hpp
-- Installing: /usr/local/include/vsomeip/plugins/pre_configuration_plugin.hpp
-- Installing: /usr/local/include/vsomeip/primitive_types.hpp
-- Installing: /usr/local/include/vsomeip/runtime.hpp
-- Installing: /usr/local/include/vsomeip/structured_types.hpp
-- Installing: /usr/local/include/vsomeip/trace.hpp
-- Installing: /usr/local/include/vsomeip/vsomeip.hpp
-- Installing: /usr/local/include/vsomeip/vsomeip_sec.h
-- Installing: /usr/local/lib/libvsomeip3.so.3.4.10
-- Installing: /usr/local/lib/libvsomeip3.so.3
-- Installing: /usr/local/lib/libvsomeip3.so
-- Installing: /usr/local/lib/libvsomeip3-e2e.so.3.4.10
-- Installing: /usr/local/lib/libvsomeip3-e2e.so.3
-- Set runtime path of "/usr/local/lib/libvsomeip3-e2e.so.3.4.10" to ""
-- Installing: /usr/local/lib/libvsomeip3-e2e.so
-- Installing: /usr/local/lib/libvsomeip3-cfg.so.3.4.10
-- Installing: /usr/local/lib/libvsomeip3-cfg.so.3
-- Set runtime path of "/usr/local/lib/libvsomeip3-cfg.so.3.4.10" to ""
-- Installing: /usr/local/lib/libvsomeip3-cfg.so
-- Installing: /usr/local/lib/libvsomeip3-sd.so.3.4.10
-- Installing: /usr/local/lib/libvsomeip3-sd.so.3
-- Set runtime path of "/usr/local/lib/libvsomeip3-sd.so.3.4.10" to ""
-- Installing: /usr/local/lib/libvsomeip3-sd.so
-- Installing: /usr/local/etc/vsomeip/vsomeip.json
-- Installing: /usr/local/etc/vsomeip/vsomeip-local.json
-- Installing: /usr/local/etc/vsomeip/vsomeip-tcp-client.json
-- Installing: /usr/local/etc/vsomeip/vsomeip-tcp-service.json
-- Installing: /usr/local/etc/vsomeip/vsomeip-udp-client.json
-- Installing: /usr/local/etc/vsomeip/vsomeip-udp-service.json
-- Installing: /usr/local/lib/cmake/vsomeip3/vsomeip3Config.cmake
-- Installing: /usr/local/lib/cmake/vsomeip3/vsomeip3ConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/vsomeip3/vsomeip3Targets.cmake
-- Installing: /usr/local/lib/cmake/vsomeip3/vsomeip3Targets-relwithdebinfo.cmake
-- Installing: /usr/local/lib/pkgconfig/vsomeip3.pc
3. 测试验证
为了验证我们编译的代码是否可用,可以参考示例说明,运行测试demo。
demo 路径和代码结构如下:
bash
cd examples/hello_world
mkdir build
cd build
cmake ..
make
编译过程如下:
编译完成后,将配置文件拷贝到demo可执行程序下:
运行 server 端程序:
bash
sudo ldconfig
env VSOMEIP_CONFIGURATION=./helloworld-local.json VSOMEIP_APPLICATION_NAME=hello_world_service ./hello_world_service
server 端:
新开一个终端,运行 client 端程序:
bash
env VSOMEIP_CONFIGURATION=./helloworld-local.json VSOMEIP_APPLICATION_NAME=hello_world_client ./hello_world_client
client 端: