Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling Freetype 2.6.5 Xcode for IOS

Tags:

freetype2

Alright guys, I posted a similar question and took it down because it wasn't specific enough so here I go. From the zip file of Freetype 2.6.5 I have not been able to create an Xcode project that will compile the library for iOS use, only for i386_64.

I tried the commands here but I don't get past the first commands the and I am getting this

FreeType build system -- automatic system detection

The following settings are used:

platform unix compiler cc
configuration directory ./builds/unix configuration rules
./builds/unix/unix.mk

If this does not correspond to your system or settings please remove the file `config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type /Applications/Xcode.app/Contents/Developer/usr/bin/make' again to build the library, or /Applications/Xcode.app/Contents/Developer/usr/bin/make refdoc' to build the API reference (this needs python >= 2.6).

cd builds/unix; \ ./configure 'CFLAGS=-arch i386' /bin/sh: ./configure: No such file or directory make: *** [setup] Error 127

I also followed the instructions inside the cmakelists.txt that it comes inside the project but still nothing, I still get an xcode project for osx and not for IOS which is giving me a plethora of linking errors. Here is the instructions for your reference.

For an iOS static library, use #

cmake -D IOS_PLATFORM=OS -G Xcode

#

or

#

cmake -D IOS_PLATFORM=SIMULATOR -G Xcode

I am not sure what else to do. Any help?

like image 325
Miguel Avatar asked Jul 15 '16 23:07

Miguel


1 Answers

Here's an outline of the basic build process to compile the FreeType libaries for iOS:

  1. Download the latest FreeType source code
  2. Extract the archive and cd into the unarchived directory
  3. Setup toolchain and export variables for the architectures desired (arm64, arm7, i386, x86_64)
  4. Compile the source code and build the libraries

For example, the build commands for arm64 might look something like this:

$ export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
$ iphoneos="7.0" # target version of iOS 
$ ARCH="arm64" # architecture (arm64, arm7, i386, x86_64)
$ export CFLAGS="-arch ${ARCH} -pipe -mdynamic-no-pic -Wno-trigraphs -fpascal-strings \
-O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden \
-miphoneos-version-min=$iphoneos -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" 
$ export AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
$ export LDFLAGS="-arch ${ARCH} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
-miphoneos-version-min=7.0"
$ ./configure --host="aarch64-apple-darwin" --enable-static=yes --enable-shared=no           
$ make     
$ clean

It's a bit of work to construct the commands for each arch, but fortunately there's a build script — which automatically downloads, extracts, and builds the latest FreeType (2.6.5 currently).

To run the script just use the following command in Terminal:

./build_freetype.sh

The resulting iOS libraries can be found in ~/Desktop/FreeType_iOS_Release when it completes.

like image 128
l'L'l Avatar answered Sep 30 '22 09:09

l'L'l