mupdf arm 交叉编译记录

本文介绍了MuPDF的交叉编译过程,适用于ARM平台。详细步骤包括下载源码、配置交叉编译链、生成文件及最终编译。适用于希望在嵌入式设备上使用MuPDF的开发者。
AI助手已提取文章相关产品:

老板催着要开发板上pdf转位图的库,mupdf看了一下应该合适,网上没有交叉编译的资料,可能是太简单了,这里做个mupdf交叉编译的记录。

MuPDF is a Free and open source software library written in C that implements a PDF and XPS parsing and rendering engine. It is used primarily to render pages into bitmaps, but also provides support for other operations such as searching and listing the table of contents and hyperlinks.

可以去官网http://mupdf.com/downloads/选择mupdf-*-source.tar.gz版本下载源码。

将对应源码放在~/tmp目录下。解压,进入源码目录,看到源码下边有makefile和makerules,这里makefile是根据makerules来对源码进行配置和编译的。我们要交叉编译自然要设置交叉编译链。

查看makerules如下:

# Configuration for the Makefile

OS ?= $(shell uname)
OS := $(OS:MINGW%=MINGW)
OS := $(OS:Windows_NT=MINGW)
OS := $(OS:Darwin=MACOS)

# The following section is an example of how to simply do cross-compilation
# using these Makefiles. It builds for a beagleboard running ARM linux,
# compiling on windows with the CodeSourcery G++ compilers.
# Invoke this as:
#      make OS=beagle-cross build=release
# This does rely on the generated directory being populated with the cmap
# files etc first. Either:
#   1) do 'make generate' first (this relies on you having an appropriate host
#   base C compiler set up - such as you would have on unix or in windows
#   cygwin)
#   2) do a non cross compile build (e.g. windows in MSVC) first.
#   3) download the generated files from mupdf.com.

ifeq "$(OS)" "beagle-cross"
CC = arm-none-linux-gnueabi-gcc
LD = arm-none-linux-gnueabi-gcc
AR = arm-none-linux-gnueabi-ar
CFLAGS += -O3 -mfpu=neon -mcpu=cortex-a8 -mfloat-abi=softfp -ftree-vectorize -ffast-math -fsingle-precision-constant
CROSSCOMPILE=yes
endif

这里开始通过OS的值来确定编译链,然后中见的注释部分提示了如何设置OS的值来编译mupdf的源码,这里可以看到我们要用的交叉编译链是arm-none-linux-gnueabi-*,但是我的编译链是arm-arago-linux-gnueabi-*,因此修改之,将ifeq "$(OS)" "beagle-cross" 下边的三个none全部改为改为arago即可。

ifeq "$(OS)" "beagle-cross"
CC = arm-arago-linux-gnueabi-gcc
LD = arm-arago-linux-gnueabi-gcc
AR = arm-arago-linux-gnueabi-ar

执行

make OS=beagle-cross build=release

提示错误,重新看下makerules里边的注释,要求先执行make generate后,因此
make generate
make OS=beagle-cross build=release

静等即可在./bulid/release目录下边看到编译好的libmupdf.a

转载于:https://www.cnblogs.com/pang1567/p/4083740.html

您可能感兴趣的与本文相关内容

### 配置和执行 MuPDF交叉编译 为了在海思平台上成功完成MuPDF交叉编译工作,需遵循一系列特定设置过程。首先,在Ubuntu环境中安装适用于目标架构(如ARM)的海思专用交叉编译工具链[^1]。 #### 设置环境变量 确保已正确设置了必要的环境变量以便调用正确的编译器和其他构建工具。这通常涉及编辑`~/.bashrc`或`/etc/profile`文件来添加如下路径: ```shell export PATH=/path/to/toolchain/bin:$PATH export CROSS_COMPILE=arm-himix200-linux-aarch64- ``` 上述命令假设使用的具体版本为`arm-himix200-linuxaarch64-himix100-linux`,实际操作时应依据实际情况调整路径与前缀。 #### 获取并准备源码 从官方仓库获取最新版MuPDF源代码,并解压至合适位置。对于依赖项如zlib等第三方库,则参照相似流程先行编译安装这些组件[^3]。 #### 编辑 Makefile 或 CMakeLists.txt 文件 针对MuPDF项目本身,可能需要修改其构建脚本以适应新的编译环境。如果采用的是基于GNU Make的方式,则重点在于更新Makefile内的CC、AR等相关字段;而对于CMake则要创建或调整`toolchain.cmake`文件指定交叉编译选项: ```cmake set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc) set(CMAKE_CXX_COMPILER ${CROSS_COMPILE}g++) ... ``` #### 执行编译指令 最后一步是在终端内切换到MuPDF根目录并通过以下方式启动编译进程: ```shell make clean && make -j$(nproc) ``` 或者如果是通过CMake管理的话则是先运行一次配置再做编译: ```shell mkdir build && cd build cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake make -j$(nproc) ``` 以上步骤完成后应该能够在海思硬件上顺利部署由主机端生成的目标二进制文件[^4]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值