Ticket #27 (closed enhancement: fixed)

Opened 20 months ago

Last modified 4 months ago

FreeBSD build

Reported by: anonymous Owned by: artem
Priority: critical (top) Milestone: 0.5.0
Component: Scons Build Scripts Version: SVN Trunk
Severity: Normal Keywords: scons
Cc: None Patch Needs Improvement: no
Needs Docmentation: no Has Patch?: yes
Design Decision Needed: no

Description

FreeBSD builds and installs boost libraries with posix threads but without the -mt suffix.

The following changes were necessary for mapnik components to build on FreeBSD. I'm just signalling the breakage: a real check or some added logic that needs to be put into the SConstruct files (by someone more well-versed than I in scons). This is just a hackish change.

svn diff

Index: bindings/python/SConscript
===================================================================
--- bindings/python/SConscript  (revision 479)
+++ bindings/python/SConscript  (working copy)
@@ -28,7 +28,7 @@
 
 linkflags = ''
 if env['THREADING'] == 'multi':
-    libraries = ['mapnik', 'boost_python%s-mt' % env['BOOST_APPEND']]
+    libraries = ['mapnik', 'boost_python%s' % env['BOOST_APPEND']]
 else :
     libraries = ['mapnik', 'boost_python%s' % env['BOOST_APPEND']]
 
Index: SConstruct
===================================================================
--- SConstruct  (revision 479)
+++ SConstruct  (working copy)
@@ -64,6 +64,9 @@
 print "Building on %s ..." % env['PLATFORM']
 Help(opts.GenerateHelpText(env))
 
+if env['PLATFORM'] == 'FreeBSD' :
+       env.Append(LIBS = 'pthread')
+
 conf = Configure(env)
 
 # Libraries and headers dependency checks
@@ -145,7 +148,7 @@
     
 for count, libinfo in enumerate(BOOST_LIBSHEADERS):
     if  env['THREADING'] == 'multi' :
-        if not conf.CheckLibWithHeader('boost_%s%s-mt' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++') and libinfo[2] :
+        if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++') and libinfo[2] :
             print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0]
             Exit(1)
     elif not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++') :
@@ -169,9 +172,9 @@
 
 # Build shapeindex and remove its dependency from the LIBS
 
-if 'boost_program_options%s-mt' % env['BOOST_APPEND'] in env['LIBS']:
+if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
     SConscript('utils/shapeindex/SConscript')
-    env['LIBS'].remove('boost_program_options%s-mt' % env['BOOST_APPEND'])
+    env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
 
 # Build the input plug-ins

Change History

Changed 19 months ago by artem

Can you run Mapnik on FreeBSD? The issue with -mt keep popping in from some linux distros, too. One hack you can do is to pass THREADING=single when compiling e.g

python scons/scons.py .... ... THREADING=single

Changed 18 months ago by gtodd

Yup, it builds and runs the demo script. I've been unable to get python PROJ4 support to work just yet because there's no python PROJ4 port/pkg for FreeBSD to make it easy :-) I will try to get this built so I can test things more fully.

Cheers,

ps: Here is a more complete diff of the SConstruct file so far.

# svn diff SConstruct          
Index: SConstruct
===================================================================
--- SConstruct  (revision 479)
+++ SConstruct  (working copy)
@@ -29,24 +29,24 @@
 
 opts = Options()
 opts.Add('PREFIX', 'The install path "prefix"', '/usr/local')
-opts.Add(PathOption('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include'))
-opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA))
+opts.Add(PathOption('BOOST_INCLUDES', 'Search path for boost include files', '/usr/local/include'))
+opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/local/' + LIBDIR_SCHEMA))
 opts.Add('BOOST_TOOLKIT','Specify boost toolkit e.g. gcc41.','',False)
-opts.Add(PathOption('FREETYPE_CONFIG', 'The path to the freetype-config executable.', '/usr/bin/freetype-config'))
-opts.Add(PathOption('FRIBIDI_INCLUDES', 'Search path for fribidi include files', '/usr/include'))
-opts.Add(PathOption('FRIBIDI_LIBS','Search path for fribidi include files','/usr/' + LIBDIR_SCHEMA))
-opts.Add(PathOption('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include'))
-opts.Add(PathOption('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA))
-opts.Add(PathOption('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include'))
-opts.Add(PathOption('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA))
-opts.Add(PathOption('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include'))
-opts.Add(PathOption('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA))
-opts.Add(PathOption('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include'))
-opts.Add(PathOption('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA))
+opts.Add(PathOption('FREETYPE_CONFIG', 'The path to the freetype-config executable.', '/usr/local/bin/freetype-config'))
+opts.Add(PathOption('FRIBIDI_INCLUDES', 'Search path for fribidi include files', '/usr/local/include'))
+opts.Add(PathOption('FRIBIDI_LIBS','Search path for fribidi include files','/usr/local/' + LIBDIR_SCHEMA))
+opts.Add(PathOption('PNG_INCLUDES', 'Search path for libpng include files', '/usr/local/include'))
+opts.Add(PathOption('PNG_LIBS','Search path for libpng include files','/usr/local/' + LIBDIR_SCHEMA))
+opts.Add(PathOption('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/local/include'))
+opts.Add(PathOption('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/local/' + LIBDIR_SCHEMA))
+opts.Add(PathOption('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/local/include'))
+opts.Add(PathOption('TIFF_LIBS', 'Search path for libtiff library files', '/usr/local/' + LIBDIR_SCHEMA))
+opts.Add(PathOption('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/local/include'))
+opts.Add(PathOption('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/local/' + LIBDIR_SCHEMA))
 opts.Add(PathOption('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include'))
 opts.Add(PathOption('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA))
 opts.Add(PathOption('GDAL_INCLUDES', 'Search path for GDAL include files', '/usr/local/include'))
-opts.Add(PathOption('GDAL_LIBS', 'Search path for GDAL library files', '/usr/local/lib' + LIBDIR_SCHEMA))
+opts.Add(PathOption('GDAL_LIBS', 'Search path for GDAL library files', '/usr/local/' + LIBDIR_SCHEMA))
 opts.Add(PathOption('GIGABASE_INCLUDES', 'Search path for Gigabase include files', '/usr/local/include'))
 opts.Add(PathOption('GIGABASE_LIBS', 'Search path for Gigabase library files', '/usr/local/' + LIBDIR_SCHEMA))
 opts.Add(PathOption('PYTHON','Python executable', sys.executable))
@@ -64,6 +64,9 @@
 print "Building on %s ..." % env['PLATFORM']
 Help(opts.GenerateHelpText(env))
 
+if env['PLATFORM'] == 'FreeBSD' :
+       env.Append(LIBS = 'pthread')
+
 conf = Configure(env)
 
 # Libraries and headers dependency checks
@@ -145,7 +148,7 @@
     
 for count, libinfo in enumerate(BOOST_LIBSHEADERS):
     if  env['THREADING'] == 'multi' :
-        if not conf.CheckLibWithHeader('boost_%s%s-mt' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++') and libinfo[2] :
+        if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++') and libinfo[2] :
             print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0]
             Exit(1)
     elif not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++') :
@@ -169,9 +172,9 @@
 
 # Build shapeindex and remove its dependency from the LIBS
 
-if 'boost_program_options%s-mt' % env['BOOST_APPEND'] in env['LIBS']:
+if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
     SConscript('utils/shapeindex/SConscript')
-    env['LIBS'].remove('boost_program_options%s-mt' % env['BOOST_APPEND'])
+    env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
 
 # Build the input plug-ins

Changed 16 months ago by artem

  • keywords Build added; None removed
  • owner changed from jfdoyon to artem
  • version set to SVN Trunk
  • component changed from OGC Server (WMS) to Core Library

Changed 16 months ago by artem

  • summary changed from None to FreeBSD build

Changed 13 months ago by wilsaj

I'm also building from FreeBSD and got it to successfully build (albeit without PROJ4 support). I also had to use this patch posted by crschmidt

I modified line 73 of scons/scons-local-0.96.1/SCons/Tool/c++.py:

     env['CXXFLAGS']   = SCons.Util.CLVar('$CCFLAGS')
-    env['CXXCOM']     = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS
     $_CPPINCFLAGS -c -o $TARGET $SOURCES'
+    env['CXXCOM']     = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS
$_CPPINCFLAGS -pthread -c -o $TARGET $SOURCES'
     env['SHCXX']      = '$CXX'

Changed 13 months ago by artem

  • status changed from new to assigned
  • milestone changed from 0.4.1 to 0.5.0

Changed 12 months ago by Beau Gunderson

Here's a patch I was working on last night:

Index: src/unicode.cpp
===================================================================
--- src/unicode.cpp     (revision 581)
+++ src/unicode.cpp     (working copy)
@@ -181,6 +181,8 @@
       size_t outleft = inleft * sizeof(wchar_t);
 #ifdef DARWIN
       const char * in = input.c_str();
+#elif FREEBSD
+      const char * in = input.c_str();
 #else
       char * in = const_cast<char*>(input.data());
 #endif
Index: bindings/python/SConscript
===================================================================
--- bindings/python/SConscript  (revision 581)
+++ bindings/python/SConscript  (working copy)
@@ -26,20 +26,25 @@
 prefix = env['PYTHON_PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
 install_prefix = env['DESTDIR'] + '/' + prefix

+thread_suffix = '-mt'
+
+if env['PLATFORM'] == 'FreeBSD':
+    thread_suffix = ''
+
 linkflags = ''
 if env['THREADING'] == 'multi':
-    libraries = ['mapnik', 'boost_python%s-mt' % env['BOOST_APPEND']]
+    libraries = ['mapnik', 'boost_python%s%s' % (env['BOOST_APPEND'],thread_suffix)]
 else :
     libraries = ['mapnik', 'boost_python%s' % env['BOOST_APPEND']]

 if env['PLATFORM'] == 'Darwin':
     if env['THREADING'] == 'multi':
-        libraries.append('boost_regex%s-mt' % env['BOOST_APPEND'])
+        libraries.append('boost_regex%s%s' % (env['BOOST_APPEND'],thread_suffix))
     else :
         libraries.append('boost_regex%s' % env['BOOST_APPEND'])

     if env['THREADING'] == 'multi':
-        libraries.append('boost_thread%s-mt' % env['BOOST_APPEND'])
+        libraries.append('boost_thread%s%s' % (env['BOOST_APPEND'],thread_suffix))

     linkflags = '-F/ -framework Python'

Index: utils/shapeindex/SConscript
===================================================================
--- utils/shapeindex/SConscript (revision 581)
+++ utils/shapeindex/SConscript (working copy)
@@ -26,6 +26,11 @@
 prefix = env['PREFIX']
 install_prefix = env['DESTDIR'] + '/' + prefix

+thread_suffix = '-mt'
+
+if env['PLATFORM'] == 'FreeBSD':
+    thread_suffix = ''
+
 source = Split(
     """
     shapeindex.cpp
@@ -38,7 +43,7 @@

 boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND']
 if env['THREADING'] == 'multi':
-    boost_program_options = '%s-mt' % boost_program_options
+    boost_program_options = '%s%s' % (boost_program_options,thread_suffix)
 shapeindex = env.Program('shapeindex', source, CPPPATH=headers, LIBS=boost_program_options)

 env.Install(install_prefix + '/bin', shapeindex)
Index: SConstruct
===================================================================
--- SConstruct  (revision 581)
+++ SConstruct  (working copy)
@@ -71,6 +71,12 @@
 color_print (4,"Building on %s ..." % env['PLATFORM'])
 Help(opts.GenerateHelpText(env))

+thread_suffix = '-mt'
+
+if env['PLATFORM'] == 'FreeBSD':
+    thread_suffix = ''
+    env.Append(LIBS = 'pthread')
+
 conf = Configure(env)

 # Libraries and headers dependency checks
@@ -152,10 +158,10 @@
     env['BOOST_APPEND'] = '-%s' % env['BOOST_TOOLKIT']
 else:
     env['BOOST_APPEND']=''
-
+
 for count, libinfo in enumerate(BOOST_LIBSHEADERS):
     if  env['THREADING'] == 'multi' :
-        if not conf.CheckLibWithHeader('boost_%s%s-mt' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++') and libinfo[2] :
+        if not conf.CheckLibWithHeader('boost_%s%s%s' % (libinfo[0],env['BOOST_APPEND'],thread_suffix), libinfo[1], 'C++') and libinfo[2] :
             color_print(1,'Could not find header or shared library for boost %s, exiting!' % libinfo[0])
             Exit(1)
     elif not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++') :
@@ -179,9 +185,9 @@

 # Build shapeindex and remove its dependency from the LIBS

-if 'boost_program_options%s-mt' % env['BOOST_APPEND'] in env['LIBS']:
+if 'boost_program_options%s%s' % (env['BOOST_APPEND'],thread_suffix) in env['LIBS']:
     SConscript('utils/shapeindex/SConscript')
-    env['LIBS'].remove('boost_program_options%s-mt' % env['BOOST_APPEND'])
+    env['LIBS'].remove('boost_program_options%s%s' % (env['BOOST_APPEND'],thread_suffix))

 # Build the input plug-ins

I also had to do the /etc/libmap.conf hack mentioned in /usr/src/UPDATING to get around the fact that mapnik was linking to libc_r (which conflicts with libpthread). After all that, I tried out the tutorial only to find it's outdated for 0.5.0 so I don't know if it actually works! I can 'import mapnik' without crashing though.

Changed 12 months ago by Beau Gunderson

Note also that I copied the DARWIN line for the const char cast, someone else got around it by just adding 'const' in front of the non-DARWIN line. Not sure which is right, but since Darwin is closer to FreeBSD than Linux I chose that route.

Changed 12 months ago by Beau Gunderson

I tested the GettingStarted tutorial against the build made from revision 581 + my patch and it worked, I was able to render png images from a number of shapefiles.

I did notice some warnings though:

python in free(): warning: modified (chunk-) pointer

Changed 12 months ago by david

  • keywords scons added; Build removed

Changed 12 months ago by Beau Gunderson

Fixed the warnings, I had a very old version of libgdal installed in /usr/local/lib/compat/pkg for some reason. Removing that and rebuilding mapnik solved everything; I have tested with a stripped-down generate_tiles.py from OSM.

Changed 11 months ago by artem

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

Fixed as far as I'm aware

Changed 4 months ago by springmeyer

  • patch_need_improvement unset
  • component changed from Core Library to Scons Build Scripts
  • priority set to critical (top)
  • need_documentation unset
  • has_patch set
  • design_decision_needed unset
Note: See TracTickets for help on using tickets.