构建CommonAPI c++ 和some/IP环境

获取common API C++

git clone https://github.com/COVESA/capicxx-core-runtime.git

第一次编译capicxx-core-runtime

cd capicxx-core-runtime/
mkdir build
cd build/
ls
cmake ..

报错 缺少 No package ‘automotive-dlt’ found

获取dlt

git clone https://github.com/GENIVI/dlt-daemon.git

cd dlt-daemon/
mkdir build
cd build/
cmake ..
make

编译dlt-daemon错误

/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 10 equals destination size [-Werror=stringop-truncation]
vi /home/hippo/CommonAPI/dlt-daemon/src/console/dlt-control-common.c
把size改成 size - 1
make
sudo make install
sudo ldconfig

第二次编译capicxx-core-runtime

安装依赖模块

  sudo apt-get install doxygen
  sudo apt-get install graphviz
  sudo apt-get install doxygen-doc doxygen-gui
  sudo apt-get install asciidoc fop

第三次编译capicxx-core-runtime

cmake ..
sudo make install
sudo ldconfig

安装CommonAPI someip

git clone https://github.com/GENIVI/capicxx-someip-runtime.git
cd capicxx-someip-runtime
mkdir build && cd build
cmake -D USE_INSTALLED_COMMONAPI=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

安装vsomeip

获取vsomeip

git clone https://github.com/COVESA/vsomeip.git

安装依赖包

sudo apt-get install source-highlight
sudo apt-get install libboost-system1.71-dev libboost-thread1.71-dev libboost-log1.71-dev
sudo apt-get install libsystemd-dev

cd vsomeip/
mkdir build
cd build/
cmake ..

编译错误

CMake Warning at examples/hello_world/CMakeLists.txt:35 (find_package):
  By not providing "Findvsomeip3.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "vsomeip3",
  but CMake did not find one.

  Could not find a package configuration file provided by "vsomeip3" with any
  of the following names:

    vsomeip3Config.cmake
    vsomeip3-config.cmake

  Add the installation prefix of "vsomeip3" to CMAKE_PREFIX_PATH or set
  "vsomeip3_DIR" to a directory containing one of the above files.  If
  "vsomeip3" provides a separate development package or SDK, be sure it has
  been installed.

修改编译命令

增加 -DCMAKE_INSTALL_PREFIX=/usr/local为编译安装目录

cmake -DENABLE_SIGNAL_HANDLING=1 -DCMAKE_INSTALL_PREFIX=/usr/local  -DDIAGNOSIS_ADDRESS=0x10 ..
make
sudo make install
sudo ldconfig

获取commonapi_core-tools_generator

下载https://github.com/COVESA/capicxx-core-tools/releases/

解压

设置link

sudo ln -s ~/CommonAPI/code_generator/commonapi_core_generator/commonapi-core-generator-linux-x86_64 /usr/bin/commonapi-core-generator-linux-x86_64


生成代码
 commonapi-core-generator-linux-x86_64 -sk fidl/E02Attributes.fidl

获取commonapi_someip_generator

下载 https://github.com/COVESA/capicxx-someip-tools/releases/

解压

设置link

sudo ln -s ~/CommonAPI/code_generator/commonapi_someip_generator/commonapi-someip-generator-linux-x86_64 /usr/bin/commonapi-someip-generator-linux-x86_64

生成代码
commonapi-someip-generator-linux-x86_64 -ll verbose fidl/E02Attributes-SomeIP.fdepl

编译Helloworld

修改CmakeList文件

# Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

cmake_minimum_required(VERSION 2.8)
project(E01HelloWorld)

#set(PROJECT_NAME E01HelloWorld)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -std=c++11")

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++11 -D_GLIBCXX_USE_NANOSLEEP -DLINUX")


# CommonAPI
include(FindPkgConfig)

# SOME/IP
find_package (CommonAPI 3.2.0 REQUIRED)
find_package (CommonAPI-SomeIP 3.2.0 REQUIRED)
find_package (vsomeip3 3.1.0 REQUIRED)

message(STATUS "COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")
message(STATUS "vsomeip3_INCLUDE_DIRS: ${VSOMEIP_INCLUDE_DIRS}")
message(STATUS, "COMMONAPI_SOMEIP_INCLUDE_DIRS: ${COMMONAPI_SOMEIP_INCLUDE_DIRS}")

# Source Files
set(PRJ_SRC_PATH src)
set(PRJ_SRC_GEN_PATH src-gen)

include_directories(
    ${PRJ_SRC_PATH}
    ${PRJ_SRC_GEN_PATH}
    ${COMMONAPI_INCLUDE_DIRS}
    ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
    ${VSOMEIP_INCLUDE_DIRS}
)

set(PRJ_NAME_CLIENT ${PROJECT_NAME}Client)
set(PRJ_NAME_SERVICE ${PROJECT_NAME}Service)

message(STATUS, "PRJ_NAME_CLIENT: ${PRJ_NAME_CLIENT}")
message(STATUS, "PRJ_NAME_SERVICE: ${PRJ_NAME_SERVICE}")

# Source Files

set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/v0/commonapi/examples)

# Application
FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp)
FILE(GLOB PRJ_DEPOLYMENT_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Deployment.cpp)
FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp)
FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp)

set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS})
set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS})

# Boost
find_package( Boost 1.54 COMPONENTS system thread log REQUIRED )
include_directories( ${Boost_INCLUDE_DIR} )

add_executable(${PRJ_NAME_CLIENT}
    ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp
    ${PRJ_PROXY_GEN_SRCS}
    ${PRJ_DEPOLYMENT_GEN_SRCS}
)

target_link_libraries(${PRJ_NAME_CLIENT} CommonAPI CommonAPI-SomeIP vsomeip3)

add_executable(${PRJ_NAME_SERVICE}
    ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp
    ${PRJ_STUB_IMPL_SRCS}
    ${PRJ_STUB_GEN_SRCS}
    ${PRJ_DEPOLYMENT_GEN_SRCS}
)

target_link_libraries(${PRJ_NAME_SERVICE} CommonAPI CommonAPI-SomeIP vsomeip3)


运行HelloWorld

启动service
./E01HelloWorldService  VSOMEIP_CONFIGURATION=…/vsomeip-local.json VSOMEIP_APPLICATION_NAME=service-sample

启动client
./E01HelloWorldClient VSOMEIP_CONFIGURATION=…/vsomeip-local.json VSOMEIP_APPLICATION_NAME=client-sample

你可能感兴趣的:(c++,git)