[ncl-install] troubl compiling NCAR graphics on new Mac OSX machine
Mary Haley
haley at ucar.edu
Tue Mar 17 10:54:14 MDT 2009
Hi Ron,
Rather than linking in libxxxx.a files specifically, it's better to
use "-L/path/to/library -lxxxx" on the compile line, and let your
system figure out whether to use the *.a file or the *.dylib file,
if there's one.
For example, instead of:
LIBS = /usr/local/ncarg/lib/libncarg.a /usr/local/ncarg/lib/libncarg_gks.a \
/usr/local/ncarg/lib/libncarg_c.a /usr/X11R6/lib/libXpm.a /usr/X11R6/lib/libX11.a \
/usr/X11R6/lib/libXext.a /usr/lib/gcc/darwin/2.95.2/libcc_dynamic.a \
/usr/lib/libSystemStubs.a /sw/lib/libg2c.a
You can use something like:
LIBPATHS = -L/usr/local/ncarg/lib -L/usr/X11R6/lib -L/sw/lib \
-L/usr/lib/gcc/darwin/2.95.2
LIBS = $(LIBPATHS) -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext \
-cc_dynamic -lSystemStubs -lg2c
However, I think your library list needs to change slightly. For
example, the PNG and Z libraries are now needed to compile NCAR
Graphics. These are usually available on your system, or you can
install them with fink.
Since "ncargex cpex08" worked for you, I recommend watching the output
when you run it, and you will see what libraries and paths are needed.
For example, if it looks something like this:
gfortran -O -o cpex08 cpexcc.f cpex08.f -L/usr/local/ncarg/lib -L/sw/lib
-L/usr/X11R6/lib -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext
-lpng -lz
Then you could change your Makefile to something like:
LIBPATHS = -L/usr/local/ncarg/lib -L/usr/X11R6/lib -L/sw/lib
LIBS = $(LIBPATHS) -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext \
-lpng -lz
Let me know if you need help getting the png and/or zlib libraries.
--Mary
On Tue, 17 Mar 2009, Ronald L. Gilliland wrote:
> Hello,
>
> I installed the new 5.1 version of NCL yesterday on
> my new Intel-based MacBook Pro running 10.5.6.
> Everything went pretty smoothly getting to the point
> of being able to run the example 'ng4ex xy01n -clean'
> producing an on screen plot, and 'ncargex cpex08'
> producing a metafile which I could display with idt,
> convert with ctrans, etc.
>
> The only way in which I want to use NCL is for Fortran
> callable graphics, which I've most recently for 5 yrs
> done on a PowerPC-based Mac running 10.3, then 10.4.
>
> My problem is knowing how to set up a make file properly
> that links in all the needed binaries. An example of
> what has worked for 5 yrs on PowerPC, linking with IBM xlf
> compiled fortran is:
>
> ----------------------------
> SHELL=/bin/sh
> #
> CFT= xlf
> FFLAGS= -O2 -qextname
> .DEFAULT: .f
> .SUFFIXES: .f
> .f.o: $*.f
> $(CFT) -c $(FFLAGS) $*.f
>
> OBJS= plser.o
>
> #
> LDFLAGS=
> LIBS= /usr/local/ncarg/lib/libncarg.a /usr/local/ncarg/lib/
> libncarg_gks.a \
> /usr/local/ncarg/lib/libncarg_c.a /usr/X11R6/lib/
> libXpm.a /usr/X11R6/lib/libX11.a \
> /usr/X11R6/lib/libXext.a /usr/lib/gcc/darwin/2.95.2/
> libcc_dynamic.a \
> /usr/lib/libSystemStubs.a /sw/lib/libg2c.a
>
> COMMAND=plser.out
>
> $(COMMAND): $(OBJS)
> $(CFT) $(LDFLAGS) -o $(COMMAND) $(OBJS) $(LIBS)
>
> clean:
> rm $(OBJS) $(COMMAND)
> ------------------------------
>
> I'm now, at least temporarily, attempting to replicate similar using
> gfortran on my Intel-based 10.5 machine.
> BUT, I'm at a loss for all of the libraries that need to be linked
> in.
> I've found the libnarg.a, libncarg_gks.a and libncarg_c.a
> under my /usr/local/lib and linked these in. The basic NCAR graphics
> calls are recognized. But, I only see 'libX11.a' etc files in a
> Developer directory with a 10.4 path, if I drill down in the one with
> a 10.5 path I see only similar files ending in 'dylib' instead of 'a'.
>
> Without great confidence I'm doing the right thing I've linked
> in the corresponding 'dylib' libraries. This led to a large number
> of previously unreferenced "X" items not being complained about.
>
> But there are still issues. Using the following makefile:
>
> -----------------------
> SHELL=/bin/sh
> #
> CFT= gfortran
> #FFLAGS= -O2 -qextname
> FFLAGS=
> .DEFAULT: .f
> .SUFFIXES: .f
> .f.o: $*.f
> $(CFT) -c $(FFLAGS) $*.f
>
> OBJS= pltest2.o
>
> #
> LDFLAGS=
> LIBS= /usr/local/lib/libncarg.a /usr/local/lib/libncarg_c.a \
> /usr/local/lib/libncarg_gks.a /sw/lib/libg2c.a \
> /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystemStubs.a \
> /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libXpm.4.dylib \
> /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libX11.6.dylib \
> /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libXext.6.dylib
>
> COMMAND=pltest2.out
>
> $(COMMAND): $(OBJS)
> $(CFT) $(LDFLAGS) -o $(COMMAND) $(OBJS) $(LIBS)
>
> clean:
> rm $(OBJS) $(COMMAND)
> --------------------------
>
> Results in problems:
> About 60 lines of the type:
> ld: warning for symbol _vctseq_ tentative definition of size 512 from /
> usr/local/lib/libncarg.a(plotif.o) is is smaller than the real
> definition of size 508 from /usr/local/lib/libncarg.a(utilbd.o)
>
> And: some still Undefined symbols:
> "_png_malloc", referenced from:
> _write_png in libncarg_gks.a(pixwrite_png.o)
> "_png_write_png", referenced from:
> _write_png in libncarg_gks.a(pixwrite_png.o)
>
> (a total of 8 of these all looking like above).
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make: *** [pltest2.out] Error 1
>
> Would anyone have a makefile for compiling codes with Fortran
> on an Intel system that shows successful specification of libraries
> that are needed? Or fairly explicit advice of what to try next,
> I've read through the install and NCL FAQs pretty extensively.
>
> And, ultimately, if this matters I'm intending to switch to Intel
> Fortran shortly.
>
> Thanks,
> Ron Gilliland
>
> _______________________________________________
> ncl-install mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-install
>
More information about the ncl-install
mailing list