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.
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.
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --disable-shared --prefix=/local/opendap-static
export PATH=/local/opendap-static/bin:${PATH}
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --disable-shared --prefix=/local/opendap-static
#############################################################################
#
# 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.
>> url = 'http://tashtego.marine.rutgers.edu:8080/thredds/dodsC/philex/gridb/averages' ; >> nc_dump ( url );... and it works.
./configure --prefix=/Users/jevans/local
export PATH=/opt/compiled/gnu/dods-3.6.2:${PATH}
./configure --prefix=/Users/jevans/local
#############################################################################
#
# 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} "
>> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc' >> nc_dump ( url );... and it works.
./configure --prefix=/opt/compiled/gnu/dods-3.6.2 --disable-shared
export PATH=/opt/compiled/gnu/dods-3.6.2:${PATH}
LD_FLAGS="-lstdc++" ./configure --prefix=/opt/compiled/gnu/dods-3.6.2 --disable-shared
#############################################################################
#
# 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} "
>> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc' >> nc_dump ( url );... and it works.
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.
The difference to notice between this case and that above is the requirement for the -fPIC flag.
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --prefix=/opt/compiled/gnu/dods-3.6.2 --disable-shared
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
#############################################################################
#
# 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} "
>> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc' >> nc_dump ( url );... and it works.
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.
CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --prefix=/p/om/compiled/gnu/dods-3.6.2 --disable-shared
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} "
>> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc' >> nc_dump ( url );... and it works.
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
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}
Other GNU packages were then installed ...
./configure --prefix=/m1/gnu
CFLAGS="-fPIC -I/m1/opendap/include" \ CXXFLAGS="-fPIC -I/m1/opendap/include" \ LDFLAGS="-L/m1/opendap/lib" \ ./configure --prefix=/m1/gnu
./configure --prefix=/m1/opendapHowever, 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.
./configure --prefix=/m1/opendap
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} "
>> url = 'http://queequeg.marine.rutgers.edu:9876/thredds/dodsC/roms/nena/in/frc_nena_2004_ncep_rain.nc' >> nc_dump ( url );... and it works.