Compiling FreeType for iPhone?

前端 未结 7 1815
一个人的身影
一个人的身影 2020-12-05 16:38

I\'m using FreeType on Windows, Linux and OSX without a single problem, and now I was to port my tech to IOS... And I can\'t find a way to have FreeType compiled for it.

相关标签:
7条回答
  • 2020-12-05 16:58

    For iOS SDK 8.1 with a min target of 7.1 on Xcode 6.1, this works:

    ./configure --without-zlib --without-png --without-bzip2 '--prefix=/usr/local/iPhone' '--host=arm-apple-darwin' '--enable-static=yes' '--enable-shared=no' 'CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' 'CFLAGS=-arch armv7 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=7.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/include/libxml2/ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/' 'AR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar' 'LDFLAGS=-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/ -miphoneos-version-min=7.0'
    
    0 讨论(0)
  • 2020-12-05 17:01

    This shell script works for me, x86_64. You maybe need to have a look.

    I used it to compile freetype2.5.5, and got armv7, arm64, i386, x86_64.Of course it lipo to a single fat static library.

    0 讨论(0)
  • For Xcode 5, gcc has moved location so the configuration should be:

    ./configure --without-zlib --without-png --without-bzip2 '--prefix=/usr/local/iPhone' '--host=arm-apple-darwin' '--enable-static=yes' '--enable-shared=no' 'CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' 'CFLAGS=-arch armv7 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=6.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/libxml2/ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/' 'AR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar' 'LDFLAGS=-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/ -miphoneos-version-min=6.1'
    

    The location of CC can be found by running:

    $ xcrun -find -sdk iphoneos clang
    
    0 讨论(0)
  • 2020-12-05 17:10

    I came across this project today while trying to compile FreeType for iOS: https://github.com/cdave1/freetype2-ios

    Just download, open in xcode, and compile. :)

    Hope this is helpful for anyone else trying to compile for iOS.

    0 讨论(0)
  • 2020-12-05 17:17

    For freetype to compile smoothly it's important to pass the variables 'CC', 'CFLAGS', 'LDFLAGS' and 'AR' as arguments to configure and not as environment variables.

    at some point configure runs the native gcc of the machine and if you have 'LDFLAGS' that point to the iphone SDK it will cause it to fail. passing the variables to configure seems to solve this issue.

    0 讨论(0)
  • 2020-12-05 17:20

    Maybe someone will find it usefull.
    SDK 8.1, XCode 6.1
    i386,x86_64,arm64 (for profiling) ,armv7,armv7s

    ./configure CFLAGS="-arch i386"
    make clean
    make
    cp objs/.libs/libfreetype.a libfreetype-i386.a
    
    ./configure CFLAGS="-arch x86_64"
    make clean
    make
    cp objs/.libs/libfreetype.a libfreetype-x86_64.a
    
    ./configure --without-zlib --without-png --without-bzip2 '--prefix=/usr/local/iPhone' '--host=arm-apple-darwin' '--enable-static=yes' '--enable-shared=no' 'CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' 'CFLAGS=-arch armv7 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=7.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/include/libxml2/ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/' 'AR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar' 'LDFLAGS=-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/ -miphoneos-version-min=7.0'
    make clean
    make
    cp objs/.libs/libfreetype.a libfreetype-armv7.a
    
    ./configure --without-zlib --without-png --without-bzip2 '--prefix=/usr/local/iPhone' '--host=arm-apple-darwin' '--enable-static=yes' '--enable-shared=no' 'CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' 'CFLAGS=-arch arm64 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=7.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/include/libxml2/ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/' 'AR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar' 'LDFLAGS=-arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/ -miphoneos-version-min=7.0'
    make clean
    make
    cp objs/.libs/libfreetype.a libfreetype-arm64.a
    
    ./configure --without-zlib --without-png --without-bzip2 '--prefix=/usr/local/iPhone' '--host=arm-apple-darwin' '--enable-static=yes' '--enable-shared=no' 'CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' 'CFLAGS=-arch armv7s -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=7.0 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/include/libxml2/ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/' 'AR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar' 'LDFLAGS=-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/ -miphoneos-version-min=7.0'
    make clean
    make
    cp objs/.libs/libfreetype.a libfreetype-armv7s.a
    
    lipo -create -output libfreetype.a libfreetype-i386.a libfreetype-x86_64.a libfreetype-armv7.a libfreetype-armv7s.a libfreetype-arm64.a 
    
    0 讨论(0)
提交回复
热议问题