黑芝麻A1000 编译代码所需的CMakeLists.txt(十一)
时间:2023-08-18 15:37:00
参考:
- linux安装protobuf3.6.1编译安装link
- UBUNTU16.04卸载安装protobuflink
- 最简单方便LINUX更改DOCKER数据(镜像/容器)的存储路径(位置)方法适用于刚安装DOCKER的情况link
- 保存对容器的修改link
正文:
1 在 xxx/heizhima/BST_A1000_SDK/BST_A1000_SDK_V1.1.1/BST_A1000_Linux_Dev_Kit/SDK-Docker-fad-1.1.1 运行:
$./run_docker.sh
进入docker编码环境
2 复制宿主机的代码docker环境中
$ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4df1234a7234 a1000-sdk-fad:1.1.1 "bash" 4 hours ago Up 4 hours 0.0.0.0:212->22/tcp a1000-sdk-fad-1.1.1 94825784bf65 bsnn_tools:3.8.0 "nohup jupyter noteb…" 6 weeks ago Exited (255) 4 weeks ago 0.0.0.0:8370->8888/tcp bsnn_tools_root ced9f8c97c3b portainer/portainer "/portainer" 2 months ago Up 4 hours 0.0.0.0:9000->9000/tcp portainer
sudo docker cp file <容器 ID>:/dir sudo docker cp xxx/code 4df1234a7234:/home/lidar
3 进入 /home/lidar/code 编译目录
CMakeLists.txt 为:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(Lidar128x1View) set(CMAKE_C_COMPILER /opt/bstos/1.1.1.3/sysroots/x86_64-bstsdk-linux/usr/bin/aarch64-bst-linux/aarch64-bst-linux-gcc) set(CMAKE_CXX_COMPILER /opt/bstos/1.1.1.3/sysroots/x86_64-bstsdk-linux/usr/bin/aarch64-bst-linux/aarch64-bst-linux-g ) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS ON) add_compile_options("-g") if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() find_package(Protobuf REQUIRED) if(PROTOBUF_FOUND) message(STATUS "protobuf library found") else() message(FATAL_ERROR "protobuf library isneeded but cant be found")
endif()
include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ch128driver.proto)
add_executable (main connect_main.cpp connect_rev.cpp connect_send.cpp ${PROTO_SRCS} ${PROTO_HDRS})
target_link_libraries (main pthread ${PROTOBUF_LIBRARIES} boost_system boost_thread)
编译:
cmake -B build
cmake --build build -j4
4 在宿主机杀死 adb daemon 进程,
adb kill-server
然后把编译好的可执行程序 pull 到黑芝麻A1000
cd build/
adb push main /home/root/lidar
5 进入黑芝麻A1000,执行
adb shell
cd /home/root/lidar
./mian
如果:
$ adb shell
error: more than one device/emulator
参考:输入adb shell 时 提示error: more than one device and emulator
$ adb devices
List of devices attached
FAD-A device
FAD-B device
$ adb -s FAD-A shell
sh-4.4#
6 保存对docker环境的更改
sudo docker commit 4df1234a7234 lidar_send/v1.1
sha256:ce2bc746f3ec8b8bb07012c67d8fd2ab5c5e3506b808b45a0839ecb73c5cbf47
7 再次运行
参考:docker学习02——docker命令
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8c13083b88b0 a1000-sdk-fad:1.1.1 "bash" 5 weeks ago Up 7 seconds 0.0.0.0:212->22/tcp a1000-sdk-fad-1.1.1
e4ef21f0c344 lidar_send/v1.1 "/bin/bash" 6 weeks ago Exited (255) 4 weeks ago 22/tcp naughty_lederberg
94825784bf65 bsnn_tools:3.8.0 "nohup jupyter noteb…" 3 months ago Exited (255) 2 months ago 0.0.0.0:8370->8888/tcp bsnn_tools_root
ced9f8c97c3b portainer/portainer "/portainer" 3 months ago Up 47 hours 0.0.0.0:9000->9000/tcp portainer
$ sudo docker exec -it e4ef21f0c344 /bin/bash
Error response from daemon: Container e4ef21f0c344f6d54362999fc2272d9412243790cde58d7789ed948d46f79612 is not running
$ sudo docker start e4ef21f0c344
e4ef21f0c344
$ sudo docker exec -it e4ef21f0c344 /bin/bash
* Starting OpenBSD Secure Shell server sshd [ OK ]