Ticket #2215 (closed defect: fixed)

Opened 9 months ago

Last modified 7 months ago

HowTo Build AGG with freetype support from sources

Reported by: woodbri Assigned to: dmorissette
Priority: normal Milestone: 5.0 release
Component: Build Problems Version: svn-trunk (development)
Severity: normal Keywords:
Cc: warmerdam, sdlime, tbonfort, jmckenna

Description (Last modified by warmerdam)

Boy was it a pain to get agg to compile with freetype support. For the record this is what I did, but agg really needs to get their autotools stuff working.

Please note that this was done against 2.5 and I probably need to pull down 2.4 and make sure this works the same. Because 2.5 is the GPL version, we have to deal with users (like me) just grabbing the latest and greatest and building it in. This might be another reason to fork 2.4 into our own source tree probably in parallel to mapserver to control the licensing issues and to just make it easier to deal with. Long term we will want to do this to fix bugs locally and maybe to enhance it.

cd /u/software/agg-2.5/examples/X11
vi Makefile
#    Change:
#    -I/usr/local/include/freetype2 \
#    To:
#    `freetype-config --cflags` \
make freetype
# this runs then bombs but creates the agg_font_freetype.o file
# which is all we care about.

cd /u/software/agg-2.5/font_freetype/
ar r libaggfontfreetype.a agg_font_freetype.o

cd /u/software/agg-2.5/src
ln -s ../font_freetype/libaggfontfreetype.a
cd /u/software/agg-2.5/
make

cd /u/software/mapserver-svn
./configure \
  --enable-ignore-missing-data \
  --enable-debug \
  --with-httpd=/usr/sbin/apache \
  --with-proj=/usr \
  --with-agg=/u/software/agg-2.5 \
  --with-gd \
  --with-gdal \
  --with-freetype \
  --with-postgis \
  --without-tiff \
  --with-wmsclient \
  --with-ogr \
  --with-wfs \

make

There is probably a better/simpler way to do this, but this worked.

Attachments

Makefile.vc (1.3 kB) - added by jmckenna on 08/10/07 08:52:06.
AGG makefile

Change History

08/08/07 15:14:42 changed by dmorissette

  • owner changed from mapserverbugs to dmorissette.
  • cc set to warmerdam, sdlime, tbonfort.
  • version changed from unspecified to svn-trunk (development).
  • milestone set to 5.0 release.

08/08/07 15:28:43 changed by warmerdam

  • description changed.

Simplify a bit and use freetype-config --cflags for include path.

08/09/07 17:32:27 changed by jmckenna

  • cc changed from warmerdam, sdlime, tbonfort to warmerdam, sdlime, tbonfort, jmckenna.

for the record here are my windows build notes:

1) use version 2.4 (2.5 has licensing issues)

2) use makefile.vc from version 2.5

3) copy the *.cpp files from \src\platform\win32\ to \src\

4) nmake /f Makefile.vc agg.lib

5) make sure mapagg.obj is referenced in the mapserver makefile.vc:

mapogcsos.obj mappostgresql.obj mapcrypto.obj mapowscommon.obj mapagg.obj \

6) Beta3 changes:

  • AGG makefile.vc

  • add include to freetype:

line 10: INCLUDEDIRS=-I..\include -I..\include\platform\win32 -I..\..\freetype-2.1.10\include

  • add obj:

line 26: agg_platform_support.obj agg_win32_bmp.obj agg_font_freetype.obj

  • add includes to freetype:

line 673: AGG_INC=-I$(AGG_DIR)\include -I$(AGG_DIR)\include\platform\win32 -I$(AGG_DIR)\font_freetype -I$(MS_BASE)\..\freetype-2.1.10\include

08/10/07 00:20:54 changed by kyngchaos

Here's my Mac OS X AGG + FreeType? instructions (as I worked out, but there may be a better way), for both AGG 2.4 and 2.5.

Don't try to generate a configure with the autogen.sh script - it will have some missing makefile macros (SDL and FreeType?), which would be more work than it's worth to locate and install. As others have pointed out, AGG's automake setup is not quite operational.

1) Do this step only if you don't want to use the Apple X11 FreeType? with AGG. ie the FreeType? framework.

Edit Makefile.in.Darwin: replace the X11 paths to the FreeType? headers to AGGCXXFLAGS prefixed by -I. ie for the FreeType? framework:

AGGCXXFLAGS = -O3 -I/Library/Frameworks/FreeType.framework/Headers

2) Edit src/Makefile: change the all: target to:

all:
	$(OBJ) ../font_freetype/agg_font_freetype.o
	$(LIB) libagg.a $(OBJ) 
	$(LIB) ../font_freetype/libaggfontfreetype.a ../font_freetype/agg_font_freetype.o

3) Edit Makefile: change the all: target to:

all:
	mkdir -p lib
	cp src/libagg.a lib/
	ranlib lib/libagg.a
	cp font_freetype/libaggfontfreetype.a lib/
	ranlib lib/libaggfontfreetype.a
	ln -sf ../font_freetype/agg_font_freetype.h include/agg_font_freetype.h

4) make

This will put the libraries in a lib subfolder of the source and symlink the AGG freetype header into the include folder, so the AGG source folder can be used as the base when configuring MapServer.

08/10/07 08:52:06 changed by jmckenna

  • attachment Makefile.vc added.

AGG makefile

08/22/07 11:31:12 changed by tamas

Added the missing includes to nmake.opt in SVN trunk r6673 The windows builders in the buildbot now contain the AGG support

(follow-up: ↓ 7 ) 08/22/07 11:38:47 changed by dmorissette

  • status changed from new to assigned.

I'm currently working on automating the build of agg_font_freetype.o on Linux through MapServer's configure and Makefile when libaggfreetype is not present.

(in reply to: ↑ 6 ) 08/22/07 12:31:36 changed by tamas

Replying to dmorissette:

I'm currently working on automating the build of agg_font_freetype.o on Linux through MapServer's configure and Makefile when libaggfreetype is not present.

Daniel,

I have some doubts it might be done easily since mapagg.cpp includes <ft2build.h> explicitly. So the agg freetype in the codebase should be isolated first by using ifdefs or so.

08/22/07 12:36:41 changed by dmorissette

I have committed a first crack at it in r6676.

With this version, when --with-agg=DIR is used, we try to build agg_font_freetype.o from source if libaggfontfreetype is missing. If both libaggfontfreetype and agg_font_freetype.cpp cannot be found then we produce an error asking to be pointed to a valid AGG source tree.

In the case where you just pass --with-agg to configure with no DIR argument (to use system libs), there is currently no check for libaggfontfreetype (AC_CHECK_LIB can't be used reliably with C++), so if libaggfontfreetype does not exist in the system lib directories you'll get a linking error at build time saying that -laggfontfreetype was not found.

08/22/07 13:09:51 changed by woodbri

Daniel, I just tested this in my configuration and it work GREAT! I like the fact that it builds agg_font_freetype.o in the mapserver directory.

I did a make clean; make in agg-2.5 and removed the .o and .a from agg-2.5/font_freetype then ran the ./configure from above in mappserver and it built and runs without any problems.

08/22/07 13:53:14 changed by dmorissette

  • status changed from assigned to closed.
  • resolution set to fixed.

Thomas has committed r6677 that fixes a few typo in my r6676 changes and improved some error messages.

Marking fixed. This version seems to work fine for everyone who has tested.

Tamas, I am not sure to undertsand the issue you were referring to, in comment:7, but if there is a build issue related to ft2build.h then pleaase open a new ticket with all the details.

10/14/07 17:49:34 changed by hobu

need this currently to get python mapscript to work on src/Makefile of agg to build a shared agg lib

shared: $(OBJ) ../font_freetype/agg_font_freetype.o
	$(CXX) -shared  -W1,-soname,libagg.2.4.so -o libagg.so \$(OBJ) ../font_freetype/agg_font_freetype.o -L/usr/local/lib -lfreetype