SourceForge.net Logo
Home | News | Download | For Developers | Credits | FAQ | OPeNDAP | Tutorial | Project

Mexnc and OPeNDAP: What Works

Some of the example steps below assume that you have snctools installed for testing purposes. All of these examples assume mexnc being at least at version 2.0.19.

Case Studies

On linux systems, it seems to be necessary to configure libdap and libnc-dap with the --disable-shared flag. Not doing so seems to always result in segmentation faults. But solaris builds seem to be ok with the pure shared library approach. Go figure.

R2007a Linux X86_64

Baseline system

  1. Compiled libdap 3.7.8 with
    CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --disable-shared --prefix=/local/opendap-static
    
  2. Compiled libnc-dap 3.7.0 with
    export PATH=/local/opendap-static/bin:${PATH}
    CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --disable-shared --prefix=/local/opendap-static
    
  3. Edit the bottom of mexopts.sh, make it read as follows
    #############################################################################
    #
    # Architecture independent lines:
    #
    #     Set and uncomment any lines which will apply to all architectures.
    #
    #----------------------------------------------------------------------------
    OPENDAP="/local/opendap-static"
    EXTRA_CFLAGS="-I${OPENDAP}/include/libnc-dap -I${OPENDAP}/include/libdap "
    EXTRA_CLIBS="-L${OPENDAP}/lib -lnc-dap -ldapclient -ldap -lstdc++ -lcurl -lgssapi_krb5 -lkrb5 -lk5crypto -lkrb5support -lcom_err -lresolv -lidn -ldl -lssl -lcrypto -lxml2 -lz -lm -lpthread "
    CFLAGS="-g $CFLAGS ${EXTRA_CFLAGS}"
    CLIBS="$CLIBS ${EXTRA_CLIBS} "
    
    The way to figure out what the EXTRA_CLIBS are is to look at how ncdump is linked in the previous step.
  4. From the unix command line, issue a "make"
  5. And finally, test it with
    >> url = 'http://tashtego.marine.rutgers.edu:8080/thredds/dodsC/philex/gridb/averages'      ;
    >> nc_dump ( url );
    
    ... and it works.

R2006b Mac OS X (Intel), Libdap 3.6.2, Libnc-dap 3.6.0

Baseline system

  1. Compiled libdap 3.6.2 with
    ./configure --prefix=/Users/jevans/local
    
  2. Compiled libnc-dap 3.6.0 with
    export PATH=/opt/compiled/gnu/dods-3.6.2:${PATH}
    ./configure --prefix=/Users/jevans/local
    
  3. Edit the bottom of mexopts.sh, make it read as follows
    #############################################################################
    #
    # Architecture independent lines:
    #
    #     Set and uncomment any lines which will apply to all architectures.
    #
    #----------------------------------------------------------------------------
    	OPENDAP="/Users/jevans/local"
    	EXTRA_CFLAGS="-I${OPENDAP}/include/libnc-dap -I${OPENDAP}/include/libdap "
        EXTRA_CLIBS="-L${OPENDAP}/lib -lnc-dap -ldap -lcurl -lssl -lcrypto -lxml2 -lz  -lm -lpthread "
    	CFLAGS="-g $CFLAGS ${EXTRA_CFLAGS}"
    	CLIBS="$CLIBS ${EXTRA_CLIBS} "
    
  4. From the unix command line, issue a "make"
  5. And finally, test it with
    >> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc'
    >> nc_dump ( url );
    
    ... and it works.

R14 Linux x86-32 Mandriva 2006, Libdap 3.6.2, Libnc-dap 3.6.0

Baseline system

  1. Compiled libdap 3.6.2 with
    ./configure --prefix=/opt/compiled/gnu/dods-3.6.2 --disable-shared
    
  2. Compiled libnc-dap 3.6.0 with
    export PATH=/opt/compiled/gnu/dods-3.6.2:${PATH}
    LD_FLAGS="-lstdc++" ./configure --prefix=/opt/compiled/gnu/dods-3.6.2 --disable-shared
    
  3. Edit the bottom of mexopts.sh, make it read as follows
    #############################################################################
    #
    # Architecture independent lines:
    #
    #     Set and uncomment any lines which will apply to all architectures.
    #
    #----------------------------------------------------------------------------
    	OPENDAP="/opt/compiled/gnu/dods-3.6.2"
    	EXTRA_CFLAGS="-I${OPENDAP}/include/libnc-dap -I${OPENDAP}/include/libdap "
    	EXTRA_CLIBS="-L${OPENDAP}/lib -lnc-dap -ldap -lcurl -lidn -lssl -lcrypto -ldl -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lpthread  -lstdc++ "
    	CFLAGS="-g $CFLAGS ${EXTRA_CFLAGS}"
    	CLIBS="$CLIBS ${EXTRA_CLIBS} "
    
  4. From the unix command line, issue a "make"
  5. And finally, test it with
    >> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc'
    >> nc_dump ( url );
    
    ... and it works.

R14 Linux x86-32 Fedora Core 5: Libdap 3.6.2, Libnc-dap 3.6.0

Baseline system

The mex-file referenced above would not work on this system. The error message given was

??? Invalid MEX-file '/home/jevans/matlab/mexcdf/mexnc-opendap/mexnc/mexnc.mexglx': 
	libssl.so.0.9.7: cannot open shared object file: No such file or directory.
So again, there is trouble resolving shared libraries appropriately when using an opendap-enabled mex-file that was compiled on another system. However, when following the same compiling steps listed in the mandriva x86 example above, I was able to produce a working Fedora-Core-5-specific opendap-enabled mex-file.

R14 Linux x86-64 DODS 3.6.2: Mandriva 2006, Libdap 3.6.2, Libnc-dap 3.6.0

Baseline system

The difference to notice between this case and that above is the requirement for the -fPIC flag.

  1. Compiled libdap 3.6.2 with
    CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --prefix=/opt/compiled/gnu/dods-3.6.2 --disable-shared
    
  2. Compiled libnc-dap 3.6.0 with
    export PATH=/opt/compiled/gnu/dods-3.6.2:${PATH}
    CFLAGS="-fPIC" CXXFLAGS="-fPIC"  LDFLAGS="-lstdc++" ./configure --prefix=/opt/compiled/gnu/dods-3.6.2 --disable-shared
    
  3. Edit the bottom of mexopts.sh, make it read as follows
    #############################################################################
    #
    # Architecture independent lines:
    #
    #     Set and uncomment any lines which will apply to all architectures.
    #
    #----------------------------------------------------------------------------
    	OPENDAP="/opt/compiled/gnu/dods-3.6.2"
    	EXTRA_CFLAGS="-I${OPENDAP}/include/libnc-dap -I${OPENDAP}/include/libdap "
    	EXTRA_CLIBS="-L${OPENDAP}/lib -lnc-dap -ldap -lcurl -lidn -lssl -lcrypto -ldl -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lpthread  -lstdc++ "
    	CFLAGS="-g $CFLAGS ${EXTRA_CFLAGS}"
    	CLIBS="$CLIBS ${EXTRA_CLIBS} "
    
  4. From the unix command line, issue a "make"
  5. And finally, test it with
    >> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc'
    >> nc_dump ( url );
    
    ... and it works.

R14 Linux x86-64 DODS 3.6.2: Scyld Beowulf release 29cz, Libdap 3.6.2, Libnc-dap 3.6.0

The above x86-64 setup did not work for this system. I know I've been harping on this, but you really have to source-compile mexnc-opendap on each system rather than trade pre-compiled mex-files.

Baseline system

  • Compiled libdap 3.6.2 with
    CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --prefix=/p/om/compiled/gnu/dods-3.6.2 --disable-shared
    
  • Compiled libnc-dap 3.6.0 with
    export PATH=/opt/compiled/gnu/dods-3.6.2:${PATH}
    CFLAGS="-fPIC" CXXFLAGS="-fPIC"  LDFLAGS="-lstdc++" ./configure --prefix=/p/om/compiled/gnu/dods-3.6.2 --disable-shared
    
  • When it came to the step on specifying flags, -lidn was rejected, because the lib64idn11-devel package does not exist on this system. It seemed to compile just fine without it.

    #############################################################################
    #
    # Architecture independent lines:
    #
    #     Set and uncomment any lines which will apply to all architectures.
    #
    #----------------------------------------------------------------------------
    	OPENDAP="/p/om/gnu/compiled/dods-3.6.2"
    	EXTRA_CFLAGS="-I${OPENDAP}/include/libnc-dap -I${OPENDAP}/include/libdap "
    	EXTRA_CLIBS="-L${OPENDAP}/lib -lnc-dap -ldap -lcurl -lssl -lcrypto -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lpthread  -lstdc++ "
    	CFLAGS="-g $CFLAGS ${EXTRA_CFLAGS}"
    	CLIBS="$CLIBS ${EXTRA_CLIBS} "
    
  • From the unix command line, issue a "make"
  • And finally, test it with
    >> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc'
    >> nc_dump ( url );
    
    ... and it works.
  • R13 Solaris 5.8 Libdap 3.6.2, Libnc-dap 3.6.0

    1. The existing system came with gcc at version 2.95.2, which is too old, so the gnu toolchain was updated. First of all, the installed solaris version of make would not compile gcc, so make-3.81 was installed.

      GCC was then configured as

      Using built-in specs.
      Target: sparc-sun-solaris2.9
      Configured with: ../gcc-4.1.1/configure --with-as=/usr/ccs/bin/as 
      	--with-ld=/usr/ccs/bin/ld --enable-threads=posix --disable-nls 
      	--enable-languages=c,c++ 
      	--prefix=/m1/gnu
      Thread model: posix
      gcc version 4.1.1
      

    2. Once gcc was compiled, the environment had to be modified just so:

      export PATH=/m1/gnu/bin:/m1/opendap/bin:${PATH}
      export LD_LIBRARY_PATH=/m1/gnu/lib:/m1/opendap/lib:${LD_LIBRARY_PATH}
      
    3. Other GNU packages were then installed ...

      • make-3.81
      • libiconv-1.9.2
      • coreutils-5.0
      all using the same configure target
      ./configure --prefix=/m1/gnu
      
    4. The following packages were then compiled, using the configuration command
      CFLAGS="-fPIC -I/m1/opendap/include"   \
      CXXFLAGS="-fPIC -I/m1/opendap/include" \
      LDFLAGS="-L/m1/opendap/lib"            \
      ./configure --prefix=/m1/gnu
      
      • libz-1.2.3
      • curl-7.15.3
      • libxml2-2.6.24
    5. Compiled libdap 3.6.2 with
      ./configure --prefix=/m1/opendap
      
      However, this failed to compile the files tests/TestFloat64.cc and tests/TestFloat32.cc . In both cases, it was necessary to insert the line
      double trunc(double x);
      
      close to the area where the error occurs.
    6. Compiled libncdap 3.6.0 with
      ./configure --prefix=/m1/opendap
      
    7. Since curl was not compiled so as to depend upon SSL, the settings in mexopts.sh are a little easier...

      #############################################################################
      #
      # Architecture independent lines:
      #
      #     Set and uncomment any lines which will apply to all architectures.
      #
      #----------------------------------------------------------------------------
      	OPENDAP="/m1/opendap"
      	EXTRA_CFLAGS="-I${OPENDAP}/include/libnc-dap -I${OPENDAP}/include/libdap "
      	EXTRA_CLIBS="-L${OPENDAP}/lib -lnc-dap -ldap -lcurl -ldl -lz -lxml2 -lz -lm -lpthread  -lstdc++ "
      	CFLAGS="-g $CFLAGS ${EXTRA_CFLAGS}"
      	CLIBS="$CLIBS ${EXTRA_CLIBS} "
      
    8. From the unix command line, issue a "make"
    9. And finally, test it with
      >> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc'
      >> nc_dump ( url );
      
      ... and it works.



    John Evans
    IMCS Rutgers University
    71 Dudley Rd, New Brunswick, NJ 08901-8521