'check library version netcdf linux

how do I determine which version of the netcdf library is installed in my system? Is there a command line? I tried to search "netcdf" and I find a bunch of files but I can't determine the version number. Is there a command to check the version of anything installed?

I am on ubuntu



Solution 1:[1]

netCDF provides the nc-config command line tool for this purpose.

To print the version.

nc-config --version

To print more information on the netCDF build you have:

nc-config --all

Solution 2:[2]

Assuming the package is installed, you can use the following command:

dpkg-query --list netcdf

Personally I don't have netcdf installed, but you will have an output like this:

$ dpkg-query --list netbase
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  netbase        5.3          all          Basic TCP/IP networking system

Solution 3:[3]

I'm adding two solutions that are more OS-agnostic than dpkg-query (which doesn't work on, e.g. Mac OS X). First, often the version information is included in the path where the package is installed, and so you can use which to display it:

$ which ncdump
/usr/local/netcdf-4.2_optimized/bin/ncdump

Second, many docstrings also include the version number, so just printing them out will do the trick. For example, print the usage instructions of ncdump by calling it with with no arguments:

$ ncdump
ncdump [-c|-h] [-v ...] [[-b|-f] [c|f]] [-l len] [-n name] [-p n[,n]] [-k] [-x] [-s] [-t|-i] [-g ...] [-w] file
       [-c]             Coordinate variable data and header information
       ...
       file             Name of netCDF file
netcdf library version 4.2 of May 23 2012 12:14:03 $

Solution 4:[4]

You can do it in a few lines of C:

#include <netcdf.h>
#include <stdio.h>

int main(void)
{
    printf("I am NetCDF version %s\n", nc_inq_libvers());
}

On my laptop that reports:

I am NetCDF version 4.1.3 of Feb 24 2014 21:05:37 $

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jhamman
Solution 2
Solution 3 Spencer Hill
Solution 4 Rob Latham