1. 下载boost
git clone https://gitee.com/add358/boost.git
2. 对boost进行进行交叉编译
2.1 查看boost库
sudo ./bootstrap.sh --show libraries
2.2 选择需要编译的库并增加位置前缀
sudo ./bootstrap.sh --without-libraries=atomic,chrono,context,coroutine,exception,graph,graph_parallel,mpi,wave --prefix=$Your path
2.3 修改生成的project-config.jam
按照下图增加交叉编译器。注意请使用你自己需要使用的编译器
2.3 进行交叉编译
./bjam
./bjam install
大约等20分钟,交叉编译就完成了。lib和头文件会安装在指定2.2中指定的路径上
3. 对VSOMEIP进行交叉编译
3.1 配置交叉编译工具
根据您自身的情况配置交叉编译工具
3.1 修改vsomeip的cmakefile
按照下图在cmakefile中添加Boost_root, boost_include_dir 和 boost_librarydir等。设置的路径为在第二章boost库的地址
3.2 编译vsomeip
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$YourPath/vsomeip/armvsomeip ..
make
make install
等待10min,vsomeip的库就编译好了
4. VSOMEIP在板上的实际应用
4.1 写一个样例程序
#include <vsomeip/vsomeip.hpp>
std::shared_ptr< vsomeip::application > app;
int main() {
app = vsomeip::runtime::get()->create_application("World");
app->init();
app->start();
}
4.2 编写CMakeLists.txt
cmake_minimum_required (VERSION 2.8)
set (CMAKE_CXX_FLAGS "-g -std=c++0x")
set (BOOST_ROOT /${YOURPATH}/armboost)
set (vsomeip3_DIR /${YOURPATH}armvsomeip/lib/cmake/vsomeip3)
set (Boost_INCLUDE_DIR /${YOURPATH}/armboost/include)
set (Boost_LIBRARY_DIR /${YOURPATH}/armboost/lib)
find_package (vsomeip3 2.6.0 REQUIRED)
find_package( Boost 1.55 COMPONENTS system thread log REQUIRED)
include_directories (
${Boost_INCLUDE_DIR}
${VSOMEIP_INCLUDE_DIRS}
)
#link_directories(${Boost_LIBRARIES} ${VSOMEIP_LIBRARIES})
add_executable(service-example ../src/service-example.cpp)
target_link_libraries(service-example vsomeip3 ${Boost_LIBRARIES})
4.3 进行编译
mkdir build & cd build
cmake ..
make