NCL Home > Documentation > Tools

nhlcc

nhlcc is a script that invokes the C compiler/linker with the proper NCAR Graphics LLU (low-level utility) and HLU (high-level utility) libraries. There are special options recognized by this script. All other arguments and options are identical to the "gcc" or "cc" command on your particular machine; arguments that include quoted strings may have to be enclosed in single quotes.

If you don't want to use nhlcc, but you want to see what libraries it pulls in, you can type "nhlcc" on the command line to see what gets included in the link line. You can then you can add this information to your own Makefile or script. It is important to note that you must define the macro "NeedFuncProto" in order for function prototyping to work correctly.

In order to run nhlcc, you must have your NCARG_ROOT environment variable set to the root directory pathname where the NCAR Graphics libraries, binaries, and include files were installed. If you are not sure what NCARG_ROOT should be set to, please check with your system administrator, or send email to ncl-talk.

Note that, on most systems, if you supply your own binary libraries in addition to the ones automatically referenced by nhlcc, all the libraries must have been created in a similar fashion.

See also nhlf77 or nhlf90 for compiling Fortran 77 or 90 programs.

See ng4ex for a script that provides you with access to tons of C HLU example programs.

Modifying nhlcc

It is possible to modify nhlcc directly if you need to change anything from the compiler it's using, compiler options, libraries being linked in, etc.

The script resides in $NCARG_ROOT/bin. You can either edit it directly (be careful if you do this, especially if other people are using it), or you can copy it to your own directory and modify it as necessary. It's a C-shell script that is pretty easy to follow.

Some things you might want to change are:

The compiler used:

set cc       = "cc"

C compile options:

set loadflags  = "-fPIC -ansi -O "

List of cairo libraries:

set cairolib = "-lcairo -lfontconfig -lpixman-1 -lfreetype -lexpat"

List of NetCDF libraries:

set extra_libs = "$extra_libs -lnetcdf -lcurl -lhdf5_hl -lhdf5 -lsz -lz"

Options

  • -ngmath

    Links in the NCAR Graphics ngmath library.

  • -cairo (Available in version 5.2.0 and later.)

    Links in the cairo libraries. This is necessary if you want your graphical output to go to the cairo PS, PDF, or PNG output formats.

  • -netcdf

    Links in the netCDF library. This library is not part of NCL, so check with your system administrator if you need it installed. You can obtain a copy of it on the Unidata NetCDF website.

  • -ncarbd

    Use this option for compilers that appear to be having trouble initializing blockdata variables. It will cause a small subroutine to be linked in that helps force the loading of blockdata initialization routines. This should no longer be an issue in version 5.1.1 or later.

  • -ngmathbd

    Just like with the "-ncarbd" option, use this option for compilers that appear to be having trouble initializing Ngmath-related blockdata variables. It will cause a small subroutine to be linked in that helps force the loading of Ngmath blockdata initialization routines.

    Note: this option doesn't need to be specified separately if you are already including the "-ncarbd" and "-ngmath" options.

    Examples

    To compile an HLU C program called "cn01c.c" and create an executable called "cn01c", type:

      nhlcc -o cn01c cn01c.c
    

    To compile an HLU C program called "xy06c.c" that depends on the NetCDF library, type:

      nhlcc xy06c.c -netcdf
    

    This will create an executable called "a.out".

  •