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
相关推荐
2501_9159184110 分钟前
iOS 开发中证书创建与管理中的常见问题
android·ios·小程序·https·uni-app·iphone·webview
00后程序员张32 分钟前
IOScer 开发环境证书包括哪些,证书、描述文件与 App ID 的协同管理实践
android·ios·小程序·https·uni-app·iphone·webview
Zfox_2 小时前
无缝穿越系统边界:节点小宝4.0如何让我的Mac/iOS像访问本地盘一样操控Windows
windows·macos·ios·节点小宝
aningxiaoxixi2 小时前
android AV 之 SimpleC2Component
android
TAEHENGV2 小时前
导入导出模块 Cordova 与 OpenHarmony 混合开发实战
android·javascript·数据库
君莫啸ོ3 小时前
Android基础-SwitchCompat自定义样式
android
5980354153 小时前
【java工具类】小数、整数转中文小写
android·java·开发语言
csj503 小时前
安卓基础之《(8)—中级控件(2)选择按钮》
android
液态不合群3 小时前
【面试题】MySQL 中的索引数量是否越多越好?为什么?
android·数据库·mysql
QING6184 小时前
Kotlin协程:Job.cancel() 和 Scope.cancel() 的区别详解!!!
android·kotlin·android jetpack