😇

iOS、macOSでのlibpng、libjpeg、libtiff、libtiffxxの静的ライブラリBuildメモ

2024/03/23に公開

結論

iOS、mac用のlibpng.a、libjpeg.a、libtiff.a、libtiffxx.aの静的ライブラリはこれで、一発で作成できた。感謝。
https://github.com/ashtons/libtiff-ios
makeするだけ。

2024年3月23日、xcode 15.3

おしまい。
以下は読む必要がない。

経緯

2024年3月22日、久しぶりにlibpngをビルドしたら上手くいかない。
xcode 15.3。
libpngはここ。
http://www.libpng.org/pub/png/libpng.html

cmakeによるbuildができると便利なのだけど、エラーとなった。
内容はcmake -G Xcode .
https://qiita.com/yugitti/items/b9ba4a13ff43197da4d5

これもいい感じで途中まで動くけど、現状は作成できなかった。
https://gist.github.com/dulacp/e1cdaf75b69f4815e075

xcodeとlibpng、どっちに問題があるのか、何の問題なのかよくわからなかった。

そこで、下を参考にコマンドで作った。
https://gist.github.com/wuhao5/8061397

ダウンロードしたフォルダーでコマンドでconfigure
◇x86-64 simulator

./configure --prefix=`pwd`/install_x86_64_sim CFLAGS="-Ofast -mios-version-min=12.0" LDFLAGS="-flto" --host=x86_64-apple-darwin CC="xcrun -sdk iphonesimulator clang -arch x86_64"
make clean && make -j8 && make install

◇arm64 simulator

./configure --prefix=`pwd`/install_arm64_sim --enable-arm-neon=api CFLAGS="-Ofast -mios-version-min=12.0" LDFLAGS="-flto" --host=arm64-apple-darwin CC="xcrun -sdk iphonesimulator clang -arch arm64"
make clean && make -j8 && make install

◇arm64 device

./configure --prefix=`pwd`/install_arm64 --enable-arm-neon=api CFLAGS="-Ofast -mios-version-min=12.0" LDFLAGS="-flto" --host=arm64-apple-darwin CC="xcrun -sdk iphoneos clang -arch arm64"
make clean && make -j8 && make install

上と下はビルドできますが,真ん中のarm64 simulatorが上手くいかない。
エラーは、

checking for zlibVersion in -lz... no
checking for z_zlibVersion in -lz... no
configure: error: zlib not installed

自分は静的ファイルが欲しかったのでx86_64のシミュレーター版とarm64の実機版をlipoでくっつけて使った。

Discussion