Monday, April 17, 2006

mingw build gnuplot on winxp

Looking into building gnuplot on windows, the prerequisites were zlib, jpeg, libpng, gd, libiconv and gnuplot. It is probable that some of these prerequisites are not absolutely necessary but I definitely wanted png output.

mingw build consist of mingw3.1.0, minimal system 1.0.10 and msys developer kit 1.0.1
editor is vim. 7-zip used for unzipping and untarring. HelpWorkshop is needed for compiling the help file. The gnuplot makefile mentions the microsoft SDK but isnt necessary if you have the help compiler.
It also has a line for sort.exe which I ignored.



01. download zlib-1.2.3.tar.gz from www.zlib.net scroll down to the link
gunzip and untar (7-zip) or MSYS shell

from an MSYS shell
./configure
make
make -n install -n shows where the files would be installed
make install


02. download jpegsrc.v6b.tar.gz from http://www.ijg.org/files/
gunzip and untar (7-zip) or MSYS shell

from an MSYS shell
./configure
make
skip the make install as it doesn't install the include file and libraries

copy to /usr/local/include/
jconfig.h, jerror.h, jpeglib.h, jmorecfg.h

copy to /usr/local/lib libjpeg.a

03. download libpng-1.2.9.tar.bz2 from sourceforge you can link from the home page
http://www.libpng.org/pub/png/libpng.html
gunzip and untar (7-zip) or MSYS shell

edit scripts/makefile.mingw
line 44 change prefix=/usr to prefix=/usr/local
lines 50,51 to the location of zlib include and lib directories
ZLIBLIB= /usr/lib to ZLIBLIB=/usr/local/lib
ZLIBINC= to ZLIBINC=/usr/local/include

from an MSYS shell
cd back to the main directory out of the scripts subdirectory
make -f scripts/makefile.mingw
once again make install doesnt work so files have to be copied
manually

copy to /usr/local/include png.h pngconf.h
copy to /usr/local/lib libpng.a libpng.dll.a


04. download from http://www.mingw.org/download.shtml
libiconv-1.9.2-mingwPORT.tar.bz2
then download
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz

gunzip and untar (7-zip) or MSYS shell
first libiconv-1.9.2.tar.gz then libiconv-1.9.2-mingwPORT.tar.bz2

from an MSYS shell
cd to the mingwPORT subdirectory

./mingwPORT.sh

Download file? (Yes) no
Unarchive file? (Yes) no
Source path? (/usr/src/libiconv-1.9.2) /d/prog/devl/temp/libiconv-1.9.2
Installation Directory? (/mingw) /usr/local
CFLAGS (-O3 -s -mms-bitfields -march=-686)

The mingwPORT.sh shell script will then compile the source code
and install the files in /usr/local.
I should mention that libiconv is probably not necessary to compile
gnuplot but since I already had it installed, it needed to be worked
into the process and documented.

05. download from http://www.boutell.com/gd/ scroll to the bottom
for the link to the download

http://www.boutell.com/gd/http/gd-2.0.33.tar.gz

gunzip and untar (7-zip) or MSYS shell

Preliminary steps before compiling gd

cd /usr/local/include -- depending on where you installed msys
could be c:\pathtomsys\msys\1.0\local\include

edit file jmorecfg.h and comment out lines 160-162 due to
confliting types with /MinGW/include/basetsd.h
use c comments /* something */

in the gd subdirectory edit gd-2.0.33/gkanji.c
comment out line 24 typedef void *iconv_t due to a
conflict with libiconv

from an MSYS shell
cd /gd-2.0.33
run configure like this
CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure

edit Makefile line 233 from -- to
DEFS = -DHAVE_CONFIG_H
DEFS = -DHAVE_CONFIG_H -DBGDWIN32 -UNONDLL

make
make install

I would like to recognize my source for the makefile change and gd.h patch

http://mailman.lyra.org/pipermail/viewcvs/2005q3/003747.html

Also although the configure completed and flagged that it couldnt find
zlib, it didnt occur to me to use CFLAGS andLDFLAGS until I saw an
email that mentioned

gdparttopng.c needs the function named gdImageCreateFromGd2Part which is
supposed to be found at the shared library named libgd.so. The object
file named gd_gd2.o provides this function for libgd.so. However, the
function gdImageCreateFromGd2Part is only defined in gd_gd2.o if you
have zlib installed.






06. download from ftp://ftp.gnuplot.info/pub/gnuplot/
ftp://ftp.gnuplot.info/pub/gnuplot/gnuplot-4.0.0.tar.gz

gunzip and untar (7-zip) or MSYS shell

Preliminary steps before compiling gnuplot
Apply the following patch to gd.h which should be located in
/usr/local/include

--- ./gd.h Sat Oct 30 12:54:58 2004
+++ ./gd.h Wed Aug 24 12:18:09 2005
@@ -22,9 +22,9 @@
#ifndef WIN32
#define NONDLL 1
#endif /* WIN32 */
-
+#define NONDLL
#ifdef NONDLL
-#define BGD_DECLARE(rt) extern rt
+#define BGD_DECLARE(rt) extern rt _stdcall
#else
#ifdef BGDWIN32
#define BGD_DECLARE(rt) __declspec(dllexport) rt __stdcall


copy the above text to some file name example: gd_h.patch

copy from /usr/local/include to /gnuplot-4.0.0/term/

gd.h
gdfx.h
gd_io.h
and the patch file gd_h.patch

from an MSYS shell
cd gnuplot-4.0.0/term

apply the patch file

patch -p0 < gd_h.patch note that -p0 is -pzero

copy /gnuplot-4.0.0/config/makefile.mgw to
/gnuplot-4.0.0/src/

edit makefile.mgw

makefile edits

DESTDIR
DESTDIR = d:/prog/devl/gnuplot-test
GCCPATH
GCCPATH = d:/prog/devl/MinGW/bin
HCWPATH
HCWPATH = d:/nonfree/HelpWorkshop-sa
MSSDK
MSSDK = d:/Program Files/Microsoft SDK
GNUSORT
GNUSORT = d:/cygwin/bin/sort.exe
FREETYPE=1 comment out this line

if you have helpworkshop installed the location of mssdk, is bypassed

cd /gnuplot-4.0.0/src
CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib make -f makefile.mgw

assuming all the above was done you should have wgnuplot.exe in you source directory
I didnt run make install yet so details on that later

0 Comments:

Post a Comment

<< Home