build libimagequant for current host

step0、参考

step1、安装依赖

所有时Terminal + Shell + GNU CoreUtils
下载时cURL
解压时tar + gzip
编译时cmakeninjagcc / GCC | Clang / LLVM
运行时
  • glibc ( libc.sold-linux-x86-64.so )

step2、使用curl命令下载libimagequant源码包 (

curl -L -o libimagequant-2.14.1.tar.gz https://github.com/ImageOptim/libimagequant/archive/refs/tags/2.14.1.tar.gz

step3、使用tar解压libimagequant源码包

tar vxf libimagequant-2.14.1.tar.gz

step4、进入libimagequant-2.14.1目录

cd libimagequant-2.14.1

step5、查看libimagequant-2.14.1目录中的内容

step6、在CMakeLists.txt中添加如下内容

add_library(imagequant_a STATIC
  libimagequant.c
  blur.c
  mediancut.c
  mempool.c
  nearest.c
  pam.c
  kmeans.c
)

set(PREFIX ${CMAKE_INSTALL_PREFIX})
set(VERSION 2.14.1)
configure_file(imagequant.pc.in imagequant.pc @ONLY)

install(TARGETS imagequant   LIBRARY                DESTINATION lib)
install(FILES                     libimagequant.h   DESTINATION include)
install(FILES ${CMAKE_BINARY_DIR}/libimagequant_a.a DESTINATION lib RENAME libimagequant.a)
install(FILES ${CMAKE_BINARY_DIR}/imagequant.pc     DESTINATION lib/pkgconfig)

step7、使用cmake命令配置编译参数

cmake [option]... -D<变量>=<值> -S <sourceDIR> -B <buildDIR>
本软件特有的变量类型默认值说明
BUILD_WITH_SSEBOOLON是否支持SSE指令

示例:

cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -G Ninja \
    -Wno-dev \
    -S . \
    -B build.d

step8、使用gmake编译并安装

make --directory=build install