Vous devez réinstaller gnuplot et son paquet dépendant. Peut-être, vous avez besoin de libpng, libgd.
Installing gnuplot on Mac OS X 10.6
I wanted to install gnuplot, the infamous data visualization tool, on my laptop running Mac OS X 10.6.6. I got the idea (probably from this page) that I should build gnuplot from its original sources. Of course, this brought in a half-mile of dependencies that also needed to be compiled, mostly via libgd. Thankfully, this libgd and Mac OS X document from the libgd wiki got me most of the way there.
If you want gnuplot on Mac OS X, you might consider DarwinPorts or Fink, package systems designed to avoid the kinds of problems I work through below. I’ve been avoiding packaging systems on my computers, but not for rational or even practical reasons.
What follows is a summary of the specific steps I needed to take to get gnuplot working on my machine. I’m posting this for future searchers of this information, including probably myself, so I’ve included verbose error messages and asides to match relevant search terms.
A couple of caveats: I’m hardly an expert on any of these libraries, or even an expert in building software for Mac OS X. This may not even be the easiest way to get gnuplot working in Mac OS X. I can’t promise these instructions will work for you, and I can’t promise to maintain them. But suggestions for improving these instructions are welcome.
Since this is a snapshot in time, and time may have advanced between the time I write this and the time you read this, we begin with a list of version numbers, which serve as a blanket caveat on the specificity of these instructions:
Mac OS X 10.6.6, with the Xcode development tools and X11 libraries installed gnuplot 4.4.2 libgd 2.0.35 zlib 1.2.5 libjpeg v8c FreeType 2.4.4 Install Xcode
If you don’t already have the Xcode development tools and X11 libraries installed, get your Mac OS X 10.6 Snow Leopard installation disc, fire it up, and install them. You won’t run the Xcode application, but the packages you’ll install use the GNU development tools that are installed with Xcode to build the software.
Set PATH
The libgd doc recommends ensuring that /usr/local/bin is at the front of your command look-up PATH. I’m not sure this was strictly necessary for me, but it couldn’t hurt. I put everything in their default install locations, which generally means /usr/local.
export PATH=/usr/local/bin:$PATH
Download and Unpack
Using the list above, visit each software website, navigate to the downloads sections, and get the latest .tar.gz archives of the source. I won’t link to them directly because open source product websites change often, and you may wish to select a specific mirror or a newer version. If you download them by clicking on them in your web browser, your browser probably saves these files in your Downloads/ directory.
For each file, unpack the archive. Each of these projects uses the best practice of having the archives unpack into a subdirectory named after the archive, so you can just double-click these files in the Finder, or run the usual commands:
cd ~/Downloads
ls -1 *.gz | xargs -n 1 tar xzvf
zlib
Build zlib:
cd ~/Downloads/zlib-1.2.5
./configure --shared && make && sudo make install
The sudo command will prompt you for your administrator password once every five minutes. You will use this for the install step for each of these packages.
libpng
If you have Mac OS X 10.6, you already have libpng 1.2 installed.
Discrepancy: I recommend that you do not attempt to build and install a new version of libpng. Mac OS X 10.6 includes libpng 1.2, and introducing libpng 1.5 on top of it will only confuse the build logic of libgd. I spent a good number of hours trying to get 1.5 to work, but every binary I built would point to the libpng 1.2 dynamic library (dylib) even while having been compiled with libpng 1.5 headers. This would subsequently crash, like so:
libpng warning: Application was compiled with png.h from libpng-1.5.1 libpng warning: Application is running with png.c from libpng-1.2.44 gd-png: fatal libpng error: Incompatible libpng version in application and library zsh: segmentation fault ./gdtest test/gdtest.png The libgd doc talks about installing libpng 1.2 on a system that doesn’t already have a version of libpng. Mac OS X 10.6 already has libpng 1.2.
It was fun learning about dynamic libraries and Mac OS X (and related operating systems). Unix relies heavily on finding dynamic libraries at runtime based on a look-up path in the environment (LD_LIBRARY_PATH), and Unix software avoids building absolute paths to libraries in binaries. Mac OS X uses the opposite philosophy: absolute paths to dynamic libraries are built into binaries as much as possible, and relative library paths and the look-up path environment variable (DYLD_LIBRARY_PATH) are possible but not recommended for security reasons. Setting DYLD_LIBRARY_PATH can confuse other libraries and packages. You can see a binary’s library paths using this command: otool -l path/to/binary
If you know how to build and install libpng 1.5 on Mac OS X and get other apps to build with both the headers and the dylib path, let me know.
Update, November 2012: Here's a solution for linking libpng 1.5 from a reader. Thanks!
libjpeg
Move to the libjpeg directory:
cd ~/Downloads/jpeg-8c
The libgd doc suggests it is necessary to set the MACOSX_DEPLOYMENT_TARGET environment variable. I assumed the value would be 10.6 in my case:
export MACOSX_DEPLOYMENT_TARGET=10.6
Build and install:
./configure --enable-shared && make && sudo make install
I did not encounter the “ltconfig: cannot guess host type” problem, but if you do, see the libgd doc.
FreeType
Move to the FreeType directory, and build and install it:
cd ~/Downloads/freetype-2.4.4
./configure && make && sudo make install
The libgd doc suggests that you need to edit include/freetype/config/ftoption.h and uncomment the line that defines TT_CONFIG_OPTION_BYTECODE_INTERPRETER, but I found that in 2.4.4 this line was already uncommented. I don’t know the story of the patent issue behind TrueType hinting.
libgd
Now it’s time to install libgd, the subject of the doc I’m cribbing from. That doc suggests several steps for setting up links to libraries and tools in order to build libgd. Run these commands:
cd ~/Downloads/gd-2.0.35
sudo ln -s /usr/X11R6/include/fontconfig /usr/local/include
ln -s `which glibtool` ./libtool
./configure --with-png=/usr/X11 --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib
Note: These arguments to configure cause gd to be built with the version of libpng that’s included with Mac OS X 10.6. Without these arguments, the build won’t find png.h, and the make step (next) will fail.
Verify that the configuration step finds the PNG, JPEG, Freetype, Fontconfig, Xpm, and pthreads libraries, with output that looks like this:
** Configuration summary for gd 2.0.34:
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
Build and install:
make && sudo make install
Test:
./gdtest test/gdtest.png
gnuplot
cd ~/Downloads/gnuplot-4.4.2
./configure
Look for ** Configuration summary for gnuplot 4.4.2:
at the end of the output and verify that it reports happy things about JPEG, GIF, and PNG support. (There’s a libpdf that’s probably worth building and installing before this point, to enable PDF output from gnuplot. I assume it’s this libpdf, but I haven’t tried it yet.)
Discrepancy: gnuplot includes an extension for Emacs, the infamous text and file manipulation environment, called gnuplot-mode. However, it appears its build process expects files that are present in Emacs 22, but not in Emacs 23. If you didn’t explicitly install Emacs 23, you’re fine: Mac OS X 10.6 ships with Emacs 22. If you have Emacs 23 installed and try to run make at this point, you’ll get this message:
Making all in lisp
emacs -batch -q -no-site-file -l ./dot.el -f batch-byte-compile gnuplot.el
Cannot open load file: subst-ksc
make[2]: *** [gnuplot.elc] Error 255
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
I haven’t yet figured out how to get gnuplot-mode to work with Emacs 23 (copying in the old lisp/international/subst-*.el files isn’t enough; hints welcome). So I just disabled the Lisp compilation step in the gnuplot build:
./configure --without-lisp-files
Now you’re ready to build and install gnuplot:
make && sudo make install
Test gnuplot by starting the interactive prompt:
gnuplot
At the gnuplot> prompt, type:
plot sin(x)
X11 starts up (which takes a second or two), and a window opens with a graph of a sine curve. Enter the quit
command to go back to the shell.
Comment vous avez installé gnuplot? Habituellement, cette erreur indique des bibliothèques manquantes (ou des liens vers des bibliothèques). – Schorsch
Oui, j'ai installé gnuplot depuis la source. En outre, suite à des suggestions pour les blogs, j'ai également installé les bibliothèques pour png indépendamment. Pourtant, ça n'a pas marché. Avez-vous une idée? – Exchhattu
Peut-être que [cette explication] (https://mailman.cae.wisc.edu/pipermail/help-octave/2005-August/017633.html) est utile. – Schorsch