building libosmscout-map-agg fails
Library for OpenStreetMap offline rendering and routing
Status: Beta
Brought to you by:
tteuling
Hello,
I've a problem compiling the libosmscout following the steps at
wiki.openstreetmap.org/wiki/Libosmscout
During the compiling process, I'm occour in this error:
make[2]: ingresso nella directory "/home/anto/Scrivania/LIBOSM/libosmscout/Demos"
Making all in src
make[3]: ingresso nella directory "/home/anto/Scrivania/LIBOSM/libosmscout/Demos/src"
make all-am
make[4]: ingresso nella directory "/home/anto/Scrivania/LIBOSM/libosmscout/Demos/src"
CXXLD DrawMapAgg
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::load_font(char const*, unsigned int, agg::glyph_rendering, char const*, long)'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::prepare_glyph(unsigned int)'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::ascender() const'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::flip_y(bool)'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::width(double)'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::font_engine_freetype_base(bool, unsigned int)'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::write_glyph_to(unsigned char*) const'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::~font_engine_freetype_base()'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::height(double)'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::hinting(bool)'
/home/anto/Scrivania/LIBOSM/libosmscout/libosmscout-map-agg/src/.libs/libosmscoutmapagg.so: undefined reference to `agg::font_engine_freetype_base::add_kerning(unsigned int, unsigned int, double*, double*)'
collect2: error: ld returned 1 exit status
make[4]: *** [DrawMapAgg] Errore 1
make[4]: uscita dalla directory "/home/anto/Scrivania/LIBOSM/libosmscout/Demos/src"
make[3]: *** [all] Errore 2
make[3]: uscita dalla directory "/home/anto/Scrivania/LIBOSM/libosmscout/Demos/src"
make[2]: *** [all-recursive] Errore 1
make[2]: uscita dalla directory "/home/anto/Scrivania/LIBOSM/libosmscout/Demos"
make[1]: *** [Demos] Errore 2
make[1]: uscita dalla directory "/home/anto/Scrivania/LIBOSM/libosmscout"
make: *** [full] Errore 2
My system is Linux 3.16.0-62-generic ~14.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
Waiting a reply... Kindest regards.
I tried to fix this a few days ago, but it looks like I have not yet succeded. I'll try to reproduce this based on a local docker image of Ubuntu. Stay tuned...
I tried to get ion to compile using various combinations of linker options - but I did not succeed.
Test-Application (conftest.cpp):
The following compiler call works under Arch-Linux:
g++ -o conftest -I/usr/include/agg2 -I/usr/include/freetype2 -laggfontfreetype -lagg -lfreetype conftest.cpp
The following call under Ubuntu does not:
g++ -o conftest -I/usr/include/agg2 -I/usr/include/freetype2 -laggfontfreetype_pic -lagg_pic -lfreetype conftest.cpp
Difference is: libaggfontfreetype is a shared library under Arch Linux, libagg and libaggfontfreetype exists in two variants under Ubunutu (pic and non-pic), the freetype support library is a static library. I found no combination that worked.
Perhaps you can try yourself again. If you find a working combination, I'll to adapt the configure.ac check and the resulting compile/link commands.
Last edit: Tim Teulings 2016-05-07
Thank you so much for you reply...
If I found a solution I will post it here.
Regards.
Sorry for late answer, but I solved this in cmake build. See this commit:
https://github.com/Framstag/libosmscout/commit/2b983a8
Can be something similar used for autoconf build?
The autoconf test is already trying do to something like that:
if test "$HASLIBFREETYPE" == "true"; then
SAVED_CXXFLAGS=$CXXFLAGS
SAVED_LDFLAGS=$LDFLAGS
CXXFLAGS="$SAVED_CXXFLAGS $LIBAGG_CFLAGS $LIBFREETYPE_CFLAGS"
HASAGGFREETYPE="false"
AC_MSG_CHECKING([for libagg support library 'aggfontfreetype_pic'])
LDFLAGS="$SAVED_LDFLAGS -laggfontfreetype_pic $LIBAGG_LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <agg2 agg_font_freetype.h="">],
[ agg::font_engine_freetype_int32 fontEngine;])]</agg2>,
[AC_MSG_RESULT([yes])
LIBAGG_LIBS="-laggfontfreetype_pic $LIBAGG_LIBS"
HASAGGFREETYPE=true],
[AC_MSG_RESULT([no])])
if test "$HASAGGFREETYPE" == "false"; then
LDFLAGS="$SAVED_LDFLAGS -laggfontfreetype $LIBAGG_LIBS"
AC_MSG_CHECKING([for libagg support library 'aggfontfreetype'])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <agg2 agg_font_freetype.h="">],
[ agg::font_engine_freetype_int32 fontEngine;])]</agg2>,
[AC_MSG_RESULT([yes])
LIBAGG_LIBS="-laggfontfreetype $LIBAGG_LIBS"],
[AC_MSG_RESULT([no])])
fi
LDFLAGS=$SAVED_LDFLAGS
CXXFLAGS=$SAVED_CXXFLAGS
fi
it is just, that on some system the link in both cases fails, so the fotnfreetype support is not corretcly detected.