Macos下交叉编译安卓的paq8px压缩算法

官方没有android的编译方法,自己编写脚本在macos下交叉编译.

下载源码: git clone https://github.com/hxim/paq8px.git

稍旧的ndk并不能编译成功,需要下载最新的ndkr27c, 最后是使用clang来编译。

复制代码
编译build.sh
复制代码
export ANDROID_NDK=/Volumes/data/Codes/AndroidNDK12479018.app/Contents/NDK



cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
	-DANDROID_ABI="arm64-v8a" \
	-DANDROID_NDK=$ANDROID_NDK \
	-DANDROID_PLATFORM=android-31 \
	..

make

修改paq8px/CMakeLists.txt, 如下,去掉clang++不支持的-march=nocona和-floop-strip-mine

复制代码
复制代码
if (NATIVECPU)
    add_definitions(-march=native -mtune=native)
else ()
#    add_definitions(-march=nocona -mtune=generic)
     add_definitions(-mtune=generic)
endif (NATIVECPU)

if (DISABLE_ZLIB)
    add_definitions(-DDISABLE_ZLIB)
endif (DISABLE_ZLIB)

if (NDEBUG)
    add_definitions(-DNDEBUG)
endif (NDEBUG)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#set(CMAKE_CXX_FLAGS "-O3 -floop-strip-mine -funroll-loops -ftree-vectorize -fgcse-sm -falign-loops=16")
set(CMAKE_CXX_FLAGS "-O3 -funroll-loops -ftree-vectorize -fgcse-sm -falign-loops=16")

运行编译,成功

复制代码
mkdir mybuild
cd mybuild
chmod +x ../build.sh


$ ../build.sh
-- The C compiler identification is Clang 18.0.3
-- The CXX compiler identification is Clang 18.0.3
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Volumes/data/Codes/AndroidNDK12479018.app/Contents/NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Volumes/data/Codes/AndroidNDK12479018.app/Contents/NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /Volumes/data/Codes/AndroidNDK12479018.app/Contents/NDK/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/arm-linux-androideabi/31/libz.so (found version "1.3.0.1")
-- IPO / LTO enabled
-- Configuring done (3.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Volumes/evo2T/src/paq8px/androidbuid
[  1%] Building CXX object CMakeFiles/paq8px.dir/ProgramChecker.cpp.o
....
2 warnings generated.
[ 97%] Building CXX object CMakeFiles/paq8px.dir/StateMapPair.cpp.o
clang++: warning: optimization flag '-fgcse-sm' is not supported [-Wignored-optimization-argument]
[ 98%] Building CXX object CMakeFiles/paq8px.dir/SimdMixer.cpp.o
clang++: warning: optimization flag '-fgcse-sm' is not supported [-Wignored-optimization-argument]
[100%] Linking CXX executable paq8px
相关推荐
zh_xuan22 分钟前
Android compose Navigation 页面导航
android·compose
luanma1509801 小时前
PHP vs C#:30字秒懂两大语言核心差异
android·开发语言·python·php·laravel
luanma1509802 小时前
Laravel 7.X核心特性深度解析
android·开发语言·php·lua·laravel
运维老曾2 小时前
Flink 1.20 使用自带jdbc source 操作步骤
android·adb·flink
Sephiroth.Ma2 小时前
Mac 提示“Docker 已损坏,无法打开”?我这样排查后 10 分钟修好
macos·docker·容器
量子炒饭大师3 小时前
【OpenClaw修炼宝典】—— 【macOS安装篇】想玩《爪子船长》复刻版却卡在安装?OpenClaw 从零环境搭建与编译全攻略 (小白避坑指南)
macos·openclaw·小龙虾·龙虾
不才小强4 小时前
macOS 屏幕录制开发完全指南:ScreenCaptureKit与音频采集实战
macos·音视频
陆业聪5 小时前
2026 年还在靠「感觉」调性能?Android Profiler 这样用才对
android·人工智能·性能优化
草莓熊Lotso5 小时前
MySQL 多表连接查询实战:内连接 + 外连接
android·运维·数据库·c++·mysql
草莓熊Lotso5 小时前
Linux 进程信号深度解析(下):信号的保存、阻塞与捕捉
android·linux·运维·服务器·数据库·c++·性能优化