aarch64-linux-gnu- 交叉编译dlib库说明

aarch64-linux-gnu- 交叉编译dlib库说明

1. 源码下载

下载 dlib库源码,dlib C++ Library

在这里插入图片描述

2. 编译安装
2.1 将 下载的源码包 dlib-19.24.zip 放入交叉编译的环境下,解压文件,并创建 build 文件夹,并创建交叉编译库的文件夹 arm_dlib
unzip dlib-19.24.zip
cd dlib-19.24
mkdir build && cd build
mkdir arm_dlib
2.1 更改CmakeLists.txt , 设置指定交叉编译器

dlib-19.24目录下打开 CmakeLists.txt并修改如下:

##  cmakelists.txt参考如下
cmake_minimum_required(VERSION 3.10)

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR aarch64)
SET(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

SET(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++)

project(v4l2_decode LANGUAGES CXX C)

SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -O0 -g -Wall")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -Wall")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -ffunction-sections -fdata-sections")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -ffunction-sections -fdata-sections")
project(dlib_project)



#############################################################################
#                                                                           #
#  READ examples/CMakeLists.txt TO SEE HOW TO USE DLIB FROM C++ WITH CMAKE  #
#                                                                           #
#############################################################################





get_directory_property(has_parent PARENT_DIRECTORY)
if(NOT has_parent)
   # When you call add_subdirectory(dlib) from a parent CMake project dlib's
   # CMake scripts will assume you want to statically compile dlib into
   # whatever you are building rather than create a standalone copy of dlib.
   # This means CMake will build dlib as a static library, disable dlib's
   # install targets so they don't clutter your project, and adjust a few other
   # minor things that are convenient when statically building dlib as part of
   # your own projects.
   #
   # On the other hand, if there is no parent CMake project or if
   # DLIB_IN_PROJECT_BUILD is set to false, CMake will compile dlib as a normal
   # standalone library (either shared or static, based on the state of CMake's
   # BUILD_SHARED_LIBS flag), and include the usual install targets so you can
   # install dlib on your computer via `make install`.  Since the only reason
   # to build this CMakeLists.txt (the one you are reading right now) by itself
   # is if you want to install dlib, we indicate as such by setting
   # DLIB_IN_PROJECT_BUILD to false.
   set(DLIB_IN_PROJECT_BUILD false)
endif()
add_subdirectory(dlib)
2.2 aarch64-linux-gnu- 交叉编译静态库到指定路径

可以交叉编译库文件到指定路径,在 dlib-19.24/build/ 目录下,输入指令:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=./build/arm_dlib ..
make install

编译安装完成后,在 arm_dlib 目录下生成了 includelib ,这样交叉编译 dlib 库就完成了。

3. 引用 dlib 库

arm_dlib复制到源码引用库的路径,在源码的 CmakeLists.txt 中添加 dlib 库头文件和库。更改如下:

include_directories(
    ../deps/arm_dlib/include
)

link_directories(

    ../deps/arm_dlib/lib
)

target_link_libraries(
    dlib
)
  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值