build matplotlib-0.98.3 on Solaris with SunStudio 12

1. Set the CBE environment (/opt/jdsbld/bin/, and export CC=$CXX, so that /usr/lib/python2.4/pycc would eventually use the C++ compiler in SunStudio.

2. Download the source code from, then apply the following patch,

---	2008-08-04 02:15:22.000000000 +0800
+++	2008-11-03 17:08:41.387138200 +0800
@@ -218,6 +218,8 @@ def get_win32_compiler():
 win32_compiler = get_win32_compiler()
 if sys.platform == 'win32' and win32_compiler == 'msvc':
     std_libs = []
+elif sys.platform == 'sunos5':
+    std_libs = ['Crun', 'Cstd']
     std_libs = ['stdc++', 'm']

@@ -298,6 +300,7 @@ def check_for_freetype():
         for d in basedirs:
             module.include_dirs.append(os.path.join(d, 'freetype2'))

+    module.include_dirs.append('/usr/include')
     print_status("freetype2", get_pkgconfig_version('freetype2'))
     if not find_include_file(module.include_dirs, 'ft2build.h'):
--- src/_backend_gdk.c	2008-08-04 02:14:18.000000000 +0800
+++ src/_backend_gdk.c	2008-11-03 17:31:32.896210699 +0800
@@ -62,6 +62,7 @@ static PyMethodDef _backend_gdk_function
     { NULL, NULL, 0 }

+extern "C"

3. Then build and install,

$ python build
$ pfexec python install

Note: this version of matplotlib requires numpy-1.1 or higher version, you need build and install a newer one since solaris only has 1.0.4.

Join the Conversation


  1. I thought this post was going to be a godsend, because I really want to use Matplotlib... However, I tried the above, and ran into more problems with version

    When compiling src/ft2font.cpp, I get the following:

    building 'matplotlib.ft2font' extension
    CC -xO3 -xarch=v8 -DNDEBUG -O -xcode=pic32 -I/opt/csw/lib/python/site-packages/numpy/core/include -I/opt/csw/include/freetype2 -I/opt/csw/include -I. -I/opt/csw/include/python2.6 -c src/ft2font.cpp -o build/temp.solaris-2.10-sun4u-2.6/src/ft2font.o
    "/opt/sunstudio12.1/prod/include/CC/Cstd/rw/traits", line 531: Error: The function "wcsstr" must have a prototype.

    There's also a number of warnings, but they come after the above.

    I'm using Python 2.6 from the distribution.

    If you have any pointers, I'd appreciate the help.

  2. Hi,
    related to the previous post, I'm trying to get the newest SVN version of matplotlib to work on OpenSolaris 2009.06 (developer repository) with SunStudio Express and Python 2.6. Your patches above worked like a charm, but only after I commented out the line

    $CC --version >/dev/null 2>&1 && is_gcc=yes

    in /usr/lib/python2.6/pyCC, because it kept detecting the Sun compiler as being gnu.
    I can now import pylab, but when I try to plot something I end up with
    File "/local/Downloads/matplotlib/lib/matplotlib/backends/", line 90, in new_figure_manager
    window = Tk.Tk()
    File "/usr/lib/python2.6/lib-tk/", line 1643, in __init__ = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
    _tkinter.TclError: Can't find a usable tk.tcl in the following directories:
    /usr/lib/tcl8.4/tk8.4 /usr/lib/tk8.4 /opt/csw/lib/tk8.4 /opt/lib/tk8.4 /opt/csw/library /opt/library /opt/tk8.4.18/library /tk8.4.18/library

    /usr/lib/tk8.4/tk.tcl: no event type or button # or keysym
    no event type or button # or keysym
    while executing
    "bind Listbox {
    %W yview scroll [expr {- (%D / 120) * 4}] units
    I'm using the following Tcl package:

    Maybe if you try Python2.6, could you check this as well, pleeease? Meanwhlie, I'll try somewhat older versions of matplotlib...
    Thanks, Martin

  3. I'm sorry that I'm crazy busy these days, that I don't have time to look at this issue. I would let you know, if I have any progress.

  4. Hi,

    after successfully building matplotlib is your intention to make it available on I would be great!

    I'm also interested in scipy and if nobody has plans to make a package to be published on, I was thinking of trying myself.


  5. Hi,

    is your intention to publish scipy and matplotlib as packages on at some point? I would really be great!!


  6. bnitz, great, it's so wonderful! And thanks so much for informing me, sorry that I did not follow up this since Aug, I'm just too busy on my new job 🙁 ...

Leave a comment

Your email address will not be published. Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha