Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#2215 closed defect (fixed)

HowTo Build AGG with freetype support from sources

Reported by: woodbri Owned by: 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 (1)

Makefile.vc (1.3 KB ) - added by jmckenna 17 years ago.
AGG makefile

Download all attachments as: .zip

Change History (12)

comment:1 by dmorissette, 17 years ago

Cc: warmerdam sdlime tbonfort added
Milestone: 5.0 release
Owner: changed from mapserverbugs to dmorissette
Version: unspecifiedsvn-trunk (development)

comment:2 by warmerdam, 17 years ago

Description: modified (diff)

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

comment:3 by jmckenna, 17 years ago

Cc: jmckenna added

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

comment:4 by kyngchaos, 17 years ago

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.

by jmckenna, 17 years ago

Attachment: Makefile.vc added

AGG makefile

comment:5 by tamas, 17 years ago

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

comment:6 by dmorissette, 17 years ago

Status: newassigned

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 comment:7 by tamas, 17 years ago

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.

comment:8 by dmorissette, 17 years ago

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.

comment:9 by woodbri, 17 years ago

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.

comment:10 by dmorissette, 17 years ago

Resolution: fixed
Status: assignedclosed

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.

comment:11 by hobu, 17 years ago

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
Note: See TracTickets for help on using tickets.