网站建设资讯

NEWS

网站建设资讯

简单导出rv1126工程环境-创新互联

建立自己RV1126工程环境

编译自己应用程序,1 在SDK的环境下进行链接编译。 2 知道应用程序需要哪些库文件和头文件,建立自己的工程环境。 这是两种是我自己经过实践摸索过来的。

创新互联网站建设由有经验的网站设计师、开发人员和项目经理组成的专业建站团队,负责网站视觉设计、用户体验优化、交互设计和前端开发等方面的工作,以确保网站外观精美、网站设计、成都网站制作易于使用并且具有良好的响应性。在SDK的环境下进行链接编译

怎么去快速编译自己应用程序,又不用关心库和头文件?

RKMedia提供了一种媒体处理方案,可支持应用软件快速开发。RKMedia在各模块基础API上做进一步封装,简化了应用开发难度。

自己编写应用程序,可以在buildroot/output/rockchip_rv1126_rv1109/build/rkmedia 这个目录下开发。

先看下这个目录下的CMakeLists.txt文件内容

# rkmedia_vi_venc_rtsp_test
#--------------------------
link_directories(${PROJECT_SOURCE_DIR}/librtsp/)
add_executable(rkmedia_vi_venc_rtsp_test rkmedia_vi_venc_rtsp_test.c ${COMMON_SRC})
add_dependencies(rkmedia_vi_venc_rtsp_test easymedia)
target_link_libraries(rkmedia_vi_venc_rtsp_test easymedia rtsp)
target_include_directories(rkmedia_vi_venc_rtsp_test PRIVATE ${CMAKE_SOURCE_DIR}/include)
install(TARGETS rkmedia_vi_venc_rtsp_test RUNTIME DESTINATION "bin")
.

cmake已经帮我们做好了,指定需要的库和头文件,我们只需要照葫芦画瓢就行,

在后面添加想要编译程序

# your_app_rk_test\
....
link_directories(${PROJECT_SOURCE_DIR}/librtsp/)
add_executable(your_app_rk_test your_app_rk_test.c ${COMMON_SRC})
add_dependencies(your_app_rk_test easymedia)
target_link_libraries(your_app_rk_test easymedia rtsp)
target_include_directories(your_app_rk_test PRIVATE ${CMAKE_SOURCE_DIR}/include)
install(TARGETS your_app_rk_test RUNTIME DESTINATION "bin")
.....

“cmake .” 生成Makefile文件。

"make " 编译即可得到可执行文件。

接下来,介绍怎么建立自己工程环境,这是今天重点想讲的。

建立自己的工程环境

突破口:

cmake编译以后,可以看到CMakeFiles目录生成一些中间文件,着重看flags.make、build.make和link.txt, 这几个文件是重要的突破口。

找到rkmedia\examples\CMakeFiles\rkmedia_vi_vo_test.dir,有对rkmedia_vi_vo_test…c文件编译的依赖描述,编译命令等。
flags.make:主要添加头文件路径,以及预编译选项C_FLAGS
build.make:添加要一起编译的.c文件

link.txt:里面是编译生成可执行文件的命令。

flags.make 经过整理

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.10

# compile C with kk/bin/arm-linux-gnueabihf-gcc
C_FLAGS = -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -DUSE_UPDATEENGINE=ON -DSUCCESSFUL_BOOT=ON  -DNDEBUG   -Wall -Wextra -Wshadow -ffast-math -fPIC -Werror -g -O0 -ggdb -gdwarf -funwind-tables -rdynamic

C_DEFINES = -DAUDIO_ALGORITHM_ENABLE -DLIBDRM -DRKAIQ

C_INCLUDES = -I/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/build/rkmedia/. 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/a3dlut 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/ablc 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/accm 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/acp 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/adebayer 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/adehaze 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/adpcc 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/ae 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/af 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/agamma 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/ahdr 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/aie 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/alsc 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/anr 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/aorb 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/asd 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/asharp 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos/awb 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/common 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/iq_parser 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/uAPI 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/xcore 
-Ikk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/libdrm 
-I/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/build/rkmedia/include/easymedia 
-I/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/build/rkmedia/include/rkmedia 
-I/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/build/rkmedia/include
 -isystem kk/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq 

只需知道需要用到哪些头文件以及头文件路径。

build.make:

...
examples/rkmedia_vi_vo_test: examples/CMakeFiles/rkmedia_vi_vo_test.dir/rkmedia_vi_vo_test.c.o
examples/rkmedia_vi_vo_test: examples/CMakeFiles/rkmedia_vi_vo_test.dir/common/sample_common_isp.c.o
examples/rkmedia_vi_vo_test: examples/CMakeFiles/rkmedia_vi_vo_test.dir/common/sample_fake_isp.c.o
examples/rkmedia_vi_vo_test: examples/CMakeFiles/rkmedia_vi_vo_test.dir/build.make
examples/rkmedia_vi_vo_test: src/libeasymedia.so.1.0.1
examples/rkmedia_vi_vo_test: /home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libliveMedia.so
examples/rkmedia_vi_vo_test: /home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libgroupsock.so
examples/rkmedia_vi_vo_test: /home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libBasicUsageEnvironment.so
examples/rkmedia_vi_vo_test: /home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libUsageEnvironment.so
examples/rkmedia_vi_vo_test: /home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/librkaiq.so
....

link.txt,经过整理

/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/bin/arm-linux-gnueabihf-gcc 
--sysroot=/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot 
-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -DUSE_UPDATEENGINE=ON -DSUCCESSFUL_BOOT=ON  -DNDEBUG  -rdynamic 
CMakeFiles/rkmedia_vi_vo_test.dir/rkmedia_vi_vo_test.c.o 

CMakeFiles/rkmedia_vi_vo_test.dir/common/sample_common_isp.c.o 
CMakeFiles/rkmedia_vi_vo_test.dir/common/sample_fake_isp.c.o  -o rkmedia_vi_vo_test  


-L/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/build/rkmedia/examples/librtsp 
-Wl,-rpath,/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/build/rkmedia/examples/librtsp:
/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/build/rkmedia/src: 
../src/libeasymedia.so.1.0.1 -ldrm -lrockchip_mpp -lliveMedia -lgroupsock -lBasicUsageEnvironment -lUsageEnvironment -lpthread -lasound -lRKAP_3A -lRKAP_ANR -lRKAP_Common -lv4l2 -lrga -lRKAP_3A -lRKAP_ANR -lRKAP_Common -lv4l2 -lrga -lrknn_runtime -lrknn_api -lrockface -lsqlite3 -lmd_share -lod_share -lrockx 
/home/zhao-debug/1126rv/0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/librkaiq.so 

这里需要有一个注意就是 --sysroot= ,加入这个选项,编译器会在这个目录的./usr/lib 和 ./usr/include 找对应的库和头文件。

整理,我们大概知道需要用到哪些库以及头文件。

库路径:
sysroot/usr/lib
rkmedia/src

需要的库:
libeasymedia.so.1.0.1
-lUsageEnvironment -lpthread -lasound -lRKAP_3A -lRKAP_ANR 
-lRKAP_Common -lv4l2 -lrga -lRKAP_3A -lRKAP_ANR -lRKAP_Common 
-lv4l2 -lrga -lrknn_runtime -lrknn_api -lrockface -lsqlite3 -lmd_share 
-lod_share -lrockx 
/usr/lib/librkaiq.so

额外目标文件:
sample_common_isp.c.o    sample_fake_isp.c.o


头文件路径:
sysroot/usr/include
sysroot/usr/include/rkaiq/common 
sysroot/usr/include/rkaiq/iq_parser 
sysroot/usr/include/rkaiq/uAPI 
sysroot/usr/include/rkaiq/xcore 
sysroot/usr/include/libdrm 

rkmedia/include/easymedia
include/rkmedia
rkmedia/include

编译器路径是

buildroot/output/rockchip_rv1126_rv1109/host/bin/arm-linux-gnueabihf-gcc

大部分库路径和头文件在下面目录的lib和库

0.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot

简单粗暴点,直接打包压缩.2.20_SDK/buildroot/output/rockchip_rv1126_rv1109/host目录

tar zcvf host.tar.gz host

将压缩包放在/opt

sudo mv host.tar.gz /opt
//解压

tar zxvf host.tar.gz

建立工程:

Makefile 内容

hide := @
ECHO := echo

G++ := /opt/host/bin/arm-linux-gnueabihf-g++
#/opt/rv1126_gcc/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
#/opt/host/bin/arm-linux-gnueabihf-g++ 

#/opt/host/bin/arm-linux-gnueabihf-g++ 
#--sysroot=/opt/host/arm-buildroot-linux-gnueabihf/sysroot
SYSROOT := --sysroot=/opt/host/arm-buildroot-linux-gnueabihf/sysroot

SOURCEAPP := rkmedia_vi_venc_test.cpp

LINKAPP := sample_common_isp.c 

TARGETAPP := rkmedia_vi_venc_test

CFLAGS :=   -I./include/rkmedia \
            -I./common   \
            -I/opt/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/easymedia   \
            -I/opt/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/common \
            -I/opt/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/xcore \
            -I/opt/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/uAPI \
            -I/opt/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/algos \
            -I/opt/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/rkaiq/iq_parser \

      
LIB_FILES := 


LD_FLAGS := -leasymedia  -ldrm -lrockchip_mpp  -lpthread -lasound \
      -lRKAP_3A -lRKAP_ANR -lRKAP_Common -lv4l2  \
      -lv4lconvert -lrga  -lrknn_api   -lrockface  \
      -lsqlite3 -lmd_share -lod_share -lrockx -lrkaiq  \
      
DCFLAGS += -DRKAIQ

all:
  $(G++)  $(SYSROOT) $(DCFLAGS) $(SOURCEAPP) $(LINKAPP) -o $(TARGETAPP) $(CFLAGS) $(LIB_FILES) $(LD_FLAGS)
  @echo $(ADD_CO)
  $(hide)$(ECHO) "Build Done ..."


make编译

可以通过交叉编译器来查看可执行文件依赖哪些文件?

使用工具查看可执行文件 依赖哪些库文件,因为这里编译的可执行文件是arm,所以要选择交叉编译工具,prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-readelf


工程模板 rv1126工程模板
需要sdk,关注 小昭debug

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


网站栏目:简单导出rv1126工程环境-创新互联
文章链接:http://cdweb.net/article/iogii.html