Static FreeType has dependencies (libfreetype.6.dylib)

2.7k views Asked by At

On OSX here. Building with make.

My settings:

./configure --enable-static=yes --enable-shared=no

I've changed nothing else from the vanilla FreeType 2.5.3 download.

This results in libfreetype.a and when added to a project (link binary with libraries) I get all sorts of build errors that I don't get with a shaded library:

"_BZ2_bzDecompress", referenced from:
  _ft_bzip2_file_fill_output in libfreetype.a(ftbzip2.o)
 "_png_create_info_struct", referenced from:
  _Load_SBit_Png in libfreetype.a(sfnt.o)
"_inflateInit2_", referenced from:
  _FT_Stream_OpenGzip in libfreetype.a(ftgzip.o)

Etc., etc.

So it get's stranger, if I build with this ./configure:

./configure --enable-static=yes --enable-shared=no  --with-png=no --with-bzip2=no --with-zlib=no

Then I can build my project okay, but when I run it I get an error saying that /opt/local/lib/libfreetype.6.dylib could not be found. Well of course not, because that's only built with a shared FreeType build.

How can I build an entirely dependency free FreeType (like the website says you can)?

Many thanks, Ian

1

There are 1 answers

2
foundry On BEST ANSWER

I found success - eventually - by adapting this answer and adding exclusions for blib.png,bzip

Ignoring the iOS pieces...

./configure CFLAGS="-arch i386" --without-zlib --without-png --without-bzip2
make clean
make
cp objs/.libs/libfreetype.a libfreetype-i386.a

./configure CFLAGS="-arch x86_64" --without-zlib --without-png --without-bzip2
make clean
make
cp objs/.libs/libfreetype.a libfreetype-x86_64.a

lipo -create -output libfreetype.a libfreetype-i386.a libfreetype-x86_64.a

This has worked for me using a mix of FreeType 2.5.5 + Yosemite + Xcode 6.2