MapServer / MapServer-import

3 stars 2 forks source link

HowTo Build AGG with freetype support from sources #2216

Closed tbonfort closed 12 years ago

tbonfort commented 12 years ago

Reporter: woodbri Date: 2007/08/08 - 21:12 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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2007/08/08 - 21:28 Simplify a bit and use freetype-config --cflags for include path.

tbonfort commented 12 years ago

Author: jmckenna Date: 2007/08/09 - 23:32 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:

tbonfort commented 12 years ago

Author: kyngchaos Date: 2007/08/10 - 06:20 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.

tbonfort commented 12 years ago

Author: tamas Date: 2007/08/22 - 17:31 Added the missing includes to nmake.opt in SVN trunk f47fc40a1ca28a70b8aad57353b7044e08c78dbf (r6673) The windows builders in the buildbot now contain the AGG support

tbonfort commented 12 years ago

Author: dmorissette Date: 2007/08/22 - 17:38 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.

tbonfort commented 12 years ago

Author: tamas Date: 2007/08/22 - 18:31 Replying to [comment:6 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 explicitly. So the agg freetype in the codebase should be isolated first by using ifdefs or so.

tbonfort commented 12 years ago

Author: dmorissette Date: 2007/08/22 - 18:36 I have committed a first crack at it in 088f0057e377c4fc04b7fd9628d58b3b07a3f86c (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.

tbonfort commented 12 years ago

Author: woodbri Date: 2007/08/22 - 19:09 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.

tbonfort commented 12 years ago

Author: dmorissette Date: 2007/08/22 - 19:53 Thomas has committed eb041d2e037d7064648d03a8d2dd477da85a2e82 (r6677) that fixes a few typo in my 088f0057e377c4fc04b7fd9628d58b3b07a3f86c (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.

tbonfort commented 12 years ago

Author: hobu Date: 2007/10/14 - 23:49 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