1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Installing PDL on Mac OS X

From pdl

Revision as of 12:43, 26 July 2010 by Punkish (Talk | contribs)
Jump to: navigation, search

(Note: This page is under rapid and iterative construction. Please expect changes in this on a regular basis -- pk)

There are two ways of installing PDL on Mac OS X. One, get a pre-built PDL package, or two, custom install PDL.


Pre-Built PDL Package

The pre-built PDL package in existence is called SciKarl. You can download the latest SciKarl build shepherded by Matthew Kenworthy.

Please note that SciKarl is built against the factory shipped Perl on Mac OS X. In other words, SciKarl gets installed under /usr/bin, and is run by Perl at /usr/bin. Some folks (including myself) are extremely nervous about doing anything with the system Perl. If you are like me, you might want to do a custom install of PDL.

Custom Installation of PDL

You might want to do a custom installation of PDL because you want to build it to your specifications, you want to build it against the Perl that you installed, and you don't want to monkey with Apple's Perl (which is also usually a version or two behind the latest Perl version). In that case, read on.

Since Mac OS X is really Unix-like, most of the custom Unix installations apply. The following are my experiences on an Intel Macbook running Snow Leopard Mac OS X 10.6.x.

Perl 5.12.1

The very thing I did was to install Perl. I downloaded and installed Perl 5.12.1. Perl installs, tests and builds without a single error on Mac OS X. It is a thing of wonder that it is about as painless as it can be for a software this complicated. When make test ends with the message, "185,000 tests passed. 100% passed" (or something like that), it is a very good feeling.

Just download Perl, untar/ungzip, go into the src directory, and type

   make test
   sudo make install

Perl and its various parts will be installed in /usr/local/. From now on, everything you will install will go into /usr/local/. Make sure to add /usr/local/bin to your shell path, so you can run your own Perl instead of Apple's Perl without having to type a complete path to Perl.


Do yourself a favor. Install cpanminus. Don't even think twice. Just go to Miyagawa's git repository, download the cpanm code, build and install it. You can read the instructions or just do the following

   git clone git://github.com/miyagawa/cpanminus.git
   cd cpanminus
   perl Makefile.PL
   make install # or sudo make install if you're non root

From now on, don't even think of using cpan. Just use cpanm. For example, to install a module called Foo::Bar::Baz, just type the following on the command line

   $ sudo cpanm Foo::Bar::Baz

and, magically, it will install. You *will* use cpanm soon.


Now, on to PDL. Ironically, having just installed cpanm, and having been reassured that cpanm is the best way to install a Perl package, we are going to do just the opposite. We are not going to install PDL with cpanm, but are going to work with our hands... no powertools.

Download PDL 2.4.6 source , untar/ungzip it, and open up perldl.conf in a text editor. It is a simple text file containing a perl hash. Every key controls a PDL component build. The file is very well documented and very easy to understand.

Note: Feel free to get the latest development version of PDL. I have installed development version 11 and it builds just as easily and well as the stable PDL version. But, for sanity sake, we will focus on version 2.4.6 here.

Preliminary Dependencies

We will install a couple of preliminary dependencies before moving on to PDL itself.


Read the notes provided by Karl Glazebrook. As he notes in red letters, IMPORTANT: For the Intel Version you MUST also install g77 for this to work.. So, get the right precomipled g77 binary for your architecture from the High Performance Computing for Mac OS X page. Since I am using an Intel machine, I got g77-intel-bin.tar.gz dated October 2006.

Untar/ungzip the binary, double click to run and install it.


Put cpanm to good use. Install ExtUtils::F77 like so

   $sudo cpanm ExtUtils::F77
   Fetching http://search.cpan.org/CPAN/authors/id/K/KG/KGB/ExtUtils-F77-1.16.tar.gz ... OK
   Configuring ExtUtils-F77-1.16 ... OK
   Building and testing ExtUtils-F77-1.16 for ExtUtils::F77 ... OK
   Successfully installed ExtUtils-F77-1.16

Perldl Conf and Dependencies

Let's examine each of the keys in %PDLCONFIG hash one by one, its settings, what it does, and how to build its dependencies.


The following controls whether or not the HTML docs will be built.

   HTML_DOCS => 1,

Setting the above to undef or 1 causes the HTML documentation to be built; 0 turns it off. I turned it on, and, on my computer, the HTML documentation was built and stored under


I moved the above to a more easy to access directory so I can now view it in Safari or another browser by just typing http://localhost/pdldocs or something simple like that. I suggest you do the same, as you will need to consult the PDL docs a lot.


The following controls the location of directory for temporary files created during the build/test process.

   TEMPDIR => undef,

Leave it as 'undef'


Decides if the output of attempts to link various function during perl Makefile.PL will be hidden when building PDL


Leave it set to 1


You can set machine specific optimizations here.

   OPTIMIZE => undef, # '-g',

Don't tinker with it unless you know what you are doing (if you know what you are doing then you shouldn't be reading my instructions anyway).


Use posix threading to make use of multiprocessor machines


Leave it as is.


   MALLOCDBG => undef,

Leave unchanged.


Do you want routines to handle bad values? I do, so I have set it to 1

   WITH_BADVAL => 1,
   # If WITH_BADVAL == 1 above, do we use NaN/Inf to represent badvalues
   # The original BADVAL implementation assigned bad-values on 
   # pdl-types. Apparently THIS IS AN EXPERIMENTAL FEATURE -- BEWARE...

You can read about bad values in the PDL documentation. I turned on bad value support, and left the other settings to 0.


Try to build Graphics/TriD. I did, and I succeeded. You should also do the same.

   WITH_3D => 1,


Build Graphics/TriD using Perl OpenGL (experimental). Again, I did, and it worked.

   USE_POGL => undef,
   POGL_VERSION => 0.62,           # minimum compatible OpenGL version
   POGL_WINDOW_TYPE => 'glut',     # use GLUT for windows

Use cpanm to install OpenGL. Here is what I did.

   $sudo cpanm OpenGL
   Fetching http://search.cpan.org/CPAN/authors/id/C/CH/CHM/OpenGL-0.63.tar.gz ... OK
   Configuring OpenGL-0.63 ... OK
   Building and testing OpenGL-0.63 for OpenGL ... OK
   Successfully installed OpenGL-0.63 (upgraded from 0.62)


I didn't mess with any of the settings below. They didn't apply to me, so I left them commented out.

   # For Mesa 3.2
   #       OPENGL_LIBS => '-L/usr/local/Mesa/lib -lGL -lGLU -lXext -lX11',
   # Mesa needs -DGL_GLEXT_LEGACY for glPolygonOffsetEXT among others
   #       OPENGL_INC => '-I/usr/include/GL/',
   # For SGI GL
   #       OPENGL_LIBS => '-lGL -lGLU -lXext -lX11',
   #       OPENGL_INC => ,
   #       OPENGL_DEFINE => ,
   # Let perl try to figure it out
   #       OPENGL_LIBS => undef,
   #       OPENGL_INC => undef,
   #       OPENGL_DEFINE => undef,


Whether or not to build the Karma interface module. It was my karma, so I did.

   WITH_KARMA => 1,        # Karma interface is deprecated, don't build
   WHERE_KARMA => undef,   # you may explicitly specify directory location

See the directions for building Karma. To build Karma libraries, I did the following:

   $ rsync -a rsync.science-software.net::karma/common/ /usr/local/karma
   $ /usr/local/karma/csh_script/install-karma

The above command downloaded the latest source code for Karma and wrote it to /usr/local/karma on my computer. Then I ran the install-karma script at /usr/local/karma/csh_script which installed/upgraded Karma for me.

The neat thing is, running /usr/local/karma/csh_script/install-karma again upgrades the Karma libraries to the latest version.


Whether or not to build the PLplot interface module, as the default settings do not build PLplot.

   WITH_PLPLOT          => 1,
   WHERE_PLPLOT_LIBS    => '/usr/local/lib/plplot-5.9.6',
   WHERE_PLPLOT_INCLUDE => '/usr/local/include/plplot',

First, I built a few dependencies. I wanted Cairo Graphics. But, Cairo/Pixman can also use Poppler to create PDF documents. I wanted that. Poppler depends on xpdf, which in turn depends on Freetype. So, I started with Freetype.

= FreeType

I downoaded the source, untarred/ungzipped it, and ran the following commands

   $ ./configure
   $ make
   $ sudo make install

Everything built without a problem, and I got the following report

   Libraries have been installed in:
   If you ever happen to want to link against installed libraries
   in a given directory, LIBDIR, you must either use libtool, and
   specify the full pathname of the library, or use the `-LLIBDIR'
   flag during linking and do at least one of the following:
      - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
        during execution
   See any operating system documentation about shared libraries for
   more information, such as the ld(1) and ld.so(8) manual pages.
libpng, libjpeg, fontconfig

I also installed the latest versions of libpng (version 1.4.3), libjpeg (version 8b), and fontconfig-2.8.10 for good measure. I am pretty sure Apple provides libpng, but it is a few versions behind. All three of them were as easy as

   $ ./configure
   $ make
   $ sudo make install

Same as above. Download the latest xpdf, untar/ungzip, then

   $ ./configure
   $ make
   $ sudo make install

I downloaded latest Poppler. Then

   $ ./configure
   $ make
   $ sudo make install
Cairo Graphics

Finally, I downloaded the latest sourcecode for both Cairo and Pixman (both are required). First Pixman

   sudo make install

Then Cairo

   cairo (version 1.8.10 [release]) will be compiled with:
   The following surface backends:
     Image:         yes (always builtin)
     Xlib:          yes
     Xlib Xrender:  yes
     Quartz:        yes
     Quartz-image:  no (disabled, use --enable-quartz-image to enable)
     XCB:           no (disabled, use --enable-xcb to enable)
     Win32:         no (requires a Win32 platform)
     OS2:           no (disabled, use --enable-os2 to enable)
     PostScript:    yes
     PDF:           yes
     SVG:           yes
     glitz:         no (disabled, use --enable-glitz to enable)
     BeOS:          no (disabled, use --enable-beos to enable)
     DirectFB:      no (disabled, use --enable-directfb to enable)
   The following font backends:
     User:          yes (always builtin)
     FreeType:      yes
     Win32:         no (requires a Win32 platform)
     Quartz:        yes
   The following functions:
     PNG functions: yes
   And the following internal features:
     gcov support:  no
     test surfaces: no (disabled, use --enable-test-surfaces to enable)
     ps testing:    yes
     pdf testing:   no (requires poppler-glib >= 0.9.2)
     svg testing:   no (requires librsvg-2.0 >= 2.15.0)
   sudo make install

Now, on to build PLplot, I downloaded version 5.9.6, and ran the following command

   $ cmake -DPLD_aqt=OFF \
   -DENABLE_java=OFF \
   -DENABLE_octave=OFF \
   -DENABLE_python=OFF \
   -DENABLE_tcl=OFF \
   -DENABLE_itcl=OFF \
   -DENABLE_tk=OFF \
   -DENABLE_itk=OFF \
   -DENABLE_ada=OFF \
   -DENABLE_ocaml=OFF \
   -DENABLE_qt=OFF \
   -DENABLE_pdl=OFF \
   -DENABLE_wxwidgets=OFF \
   -DPLD_wxwidgets=OFF \
   -DPL_FREETYPE_FONT_PATH=/usr/local/share/fonts/default/TrueType \
   -DFREETYPE_INCLUDE_DIR=/usr/local/include/freetype2 \
   -DFREETYPE_LIBRARY=/usr/local/lib/libfreetype.dylib \
   -DPLD_png=ON \
   -DPLD_gif=ON \
   -DPLD_jpeg=ON \
   -DPLD_pngcairo=ON \
   -DPLD_svgcairo=ON \

Note, I had to install cmake, and since I wanted AGG support, I had to install AGG as well (AGG is Anti-grain Geometry). Leave it off if you don't want it.

Note that PLplot libraries are installed in /usr/local/lib/plplot-5.9.6 and /usr/local/include/plplot, hence the settings for PLplot in perldl.conf look like so

   WITH_PLPLOT          => 1,
   WHERE_PLPLOT_LIBS    => '/usr/local/lib/plplot-5.9.6',
   WHERE_PLPLOT_INCLUDE => '/usr/local/include/plplot',

One additional issue I had was that PLplot kept on finding Apple's older graphics libraries under the X11R6 install directory. This resulted in no png output enabled for PLplot. I couldn't figure a way out, but from a suggestion on the mailing list, I renamed the X11R6 directories temporarily and then built PLplot. That seemed to do the trick, but I am sure there is a better method.


Whether or not to build the PDL::Slatec module

   WITH_SLATEC => 0,

I turned SLATEC off as I wasn't able to make it work.


Whether or not to build the PDL::Minuit module:

   WITH_MINUIT => 0,
   MINUIT_LIB => undef

I set WITH_MINUIT to 0.


   WITH_GSL => 0,
   GSL_LIBS => undef, # use gsl-config
   GSL_INC => undef, # use gsl-config

Even though I was able to install GSL successfully, for some reason I was unable to build PDL::GSL.


Whether or not to build the PDL::FFTW module

   WITH_FFTW => 0,
   # Location to search for the FFTW libs
   FFTW_LIBS => [ '/lib','/usr/lib','/usr/local/lib'],
   # Location to find FFTW includes:
   FFTW_INC => ['/usr/include/','/usr/local/include'],
   # FFTW Numeric Precision Type to link in: (double or single precision)
    FFTW_TYPE => 'double',

Iniitially I tried setting WITH_FFTW to 1. Note that you need FFTW version 2 and ""not"" version 3.x.


Whether or not to build the PDL::IO::HDF module:

   WITH_HDF => 0,
   HDF_LIBS => 0,
   HDF_INC => 0,

At some point I would like to experiment with HDF, but for now, I just wanted to move on. So, I turned off WITH_HDF.


Whether or not to build the PDL::IO::GD module

   WITH_GD => undef,
   GD_LIBS => undef,
   GD_INC => undef,

I left the above to undef which caused the PDL::IO::GD module to be built. To build GD, I first started with GD's dependencies. The first stop was FreeType 2.3.9. After downloading the source, I untarred/ungzipped it, and ran the following commands:

   $ ./configure
   $ make
   $ sudo make install

Everything built without a problem, and I got the following report:

   Libraries have been installed in:
   If you ever happen to want to link against installed libraries
   in a given directory, LIBDIR, you must either use libtool, and
   specify the full pathname of the library, or use the `-LLIBDIR'
   flag during linking and do at least one of the following:
      - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
        during execution
   See any operating system documentation about shared libraries for
   more information, such as the ld(1) and ld.so(8) manual pages.

I also installed the latest versions of libpng (version 1.4.3), libjpeg (version 8b), and fontconfig version 2.8.10 for good measure. All three of them were as easy as:

   $ ./configure
   $ make
   $ sudo make install

Then I downloaded the latest code for libgd (2.0.35 as of this installation), untarred/ungzipped it, went into the source directory built it. Everything worked, and I got the following report:

   $ ./configure
   ** Configuration summary for gd 2.0.35:
      Support for PNG library:          yes
      Support for JPEG library:         yes
      Support for Freetype 2.x library: yes
      Support for Fontconfig library:   yes
      Support for Xpm library:          yes
      Support for pthreads:             yes
   $ make
   $ sudo make install
    /usr/bin/install -c -m 644 'gd.h' '/usr/local/include/gd.h'
    /usr/bin/install -c -m 644 'gdfx.h' '/usr/local/include/gdfx.h'
    /usr/bin/install -c -m 644 'gd_io.h' '/usr/local/include/gd_io.h'
    /usr/bin/install -c -m 644 'gdcache.h' '/usr/local/include/gdcache.h'
    /usr/bin/install -c -m 644 'gdfontg.h' '/usr/local/include/gdfontg.h'
    /usr/bin/install -c -m 644 'gdfontl.h' '/usr/local/include/gdfontl.h'
    /usr/bin/install -c -m 644 'gdfontmb.h' '/usr/local/include/gdfontmb.h'
    /usr/bin/install -c -m 644 'gdfonts.h' '/usr/local/include/gdfonts.h'
    /usr/bin/install -c -m 644 'gdfontt.h' '/usr/local/include/gdfontt.h'
    /usr/bin/install -c -m 644 'entities.h' '/usr/local/include/entities.h'


Whether or not to build the PDL::GIS::Proj module

   WITH_PROJ => undef,
   PROJ_LIBS => undef,
   PROJ_INC => undef,

I wanted WITH_PROJ on, so I left the above to undef. PDL built against my PROJ library successfully. To build PROJ 4, I downloaded the latest code from the OSGeo web site. Once again, the configure, make, make install dance worked flawlessly.

   $ ./configure
   $ make
   $ sudo make install


Do we build PDL::IO::Browser ? The perldl.conf says that there is some problem building it on OS X... something to do with curses


I left it set to 0.


Quiet Astro::FITS::Header warnings for PDL build process by default:

   FITS_LEGACY => 1,

It was set to 1, and I left it at 1. I installed Astro::FITS::CFITSIO, for which, I had to install cfitsio, but, once again, a no hassle installation. First download latest cfitsio, and then

   $ ./configure
   $ make
   $ sudo make install

Funnily, the make install step above did not work for me. So, I manually copied the lib and include files to the correct place like so (Note: ~/src/cfitsio is the directory with the cfitsio source code that I just configured and on which I ran make above.

   ~/src/cfitsio $ sudo cp lib/*.* /usr/local/lib
   ~/src/cfitsio $ sudo cp lib/pkgconfig/*.* /usr/local/lib/pkgconfig
   ~/src/cfitsio $ sudo cp include/*.* /usr/local/include

Then, install Astro::FITS::CFITSIO with cpanm

   $sudo cpanm Astro::FITS::CFITSIO
   Fetching http://search.cpan.org/CPAN/authors/id/P/PR/PRATZLAFF/Astro-FITS-CFITSIO-1.05.tar.gz ... OK
   Configuring Astro-FITS-CFITSIO-1.05 ... OK
   Building and testing Astro-FITS-CFITSIO-1.05 for Astro::FITS::CFITSIO ... OK
   Successfully installed Astro-FITS-CFITSIO-1.05


Should we use the new Devel::REPL perldl?


I wanted to try out Chris Marshall's pdl2> shell, so I built Devel::REPL. It builds successfully, and PDL builds fine against it.

   $sudo cpanm Devel::REPL
   Fetching http://search.cpan.org/CPAN/authors/id/F/FR/FREW/Devel-REPL-1.003011.tar.gz ... OK
   Configuring Devel-REPL-1.003011 ... OK
   Building and testing Devel-REPL-1.003011 for Devel::REPL ... OK
   Successfully installed Devel-REPL-1.003011


That's it for the configuration file. Now, within the PDL source directory, run the following command:

   $ perl Makefile.PL

Look at the errors. Most likely there won't be any. If there are, holler on the mailing list, and get help. Otherwise, before going on further you have one little tinkering to do to enable PLplot. The LDDLFLAGS are still set incorrectly for Mac OS X in the Graphics/PLplot/Makefile (note, the Makefile was generated by the perl Makefile.PL command). Change the following line:

   LDDLFLAGS =  -shared -L/usr/local/lib -L/usr/local/lib


   LDDLFLAGS = -bundle -undefined dynamic_lookup -L/usr/local/lib

Save the Makefile, then go two levels up to the PDL source directory and run:

   $ make

If there are no errors, run the following command:

   $ sudo make install

PDL is now installed! Enjoy.

Personal tools