Troubleshooting and FAQ

First of all, about 95% of all the problems reported to me have to do with installing the mex-file on windows. If you have R2008b or higher, there's no longer much need to do that because MATLAB has native netcdf support now. But if you are still stuck with R2008a or below and can't get a working installation going, read on...

  1. What does "failed to map segment from shared object: operation not permitted" mean?
  2. Ok, I followed your instructions for win32, so why do I get "access denied" with respect to the mex-file?
  3. It still doesn't work!!! Now I get "the specified module could not be found"
  4. I don't see netcdf.dll in the windows distribution. Where is it?
  5. I just downloaded the Windows R2006a version. So where's mexnc.dll?
  6. How can I test mexnc?
  7. MATLAB complains about GLIBC_2.3 on R14 Linux x86
  8. Why does the test suite fail on me?
  9. Why do I get the following message everytime I use SNCTOOLS with java?
     ??? Error using ==> snctools\private\nc_info_java
    Could not open netCDF URL.
    
  10. What about the NetCDF Toolbox?
  11. I get "??? Invalid MEX-file" when trying to compile with linux. What's up with that?
  1. Q: What does "failed to map segment from shared object: operation not permitted" mean?

    A: This might show up on linux if the partion under which you installed mexnc is mounted with the noexec option. Check your /etc/fstab file to see if this is the case. If it is, you need to either remove the noexec option and remount the partition, or just move mexnc to another partition.

  2. Q: Ok, I followed your instructions for win32, so why do I get "access denied" with respect to the mex-file?

    A: Check that the folder containing "mexnc.mexw32" has appropriate permissions. Specifically,

    1. Right click on the folder containing the mex-file
    2. Click on the "Security" tab.
    3. Do you have "Full control"?
    You also may want to check with your IT staff as to whether or not any security policies are in place that prevent third party applications from functioning.
  3. Q: It still doesn't work!!! Now I get the specified module could not be found

    A: Check the location where you actually placed the netcdf.dll. It must lie somewhere on your system path. Not your matlab path, but your system path. Something like either C:\path\to\matlab\bin or C:\path\to\matlab\bin\win32

  4. Q: I don't see the file "netcdf.dll" file. Where is it?

    A: If you have the download for R2008b, you don't need it. Otherwise check the download instructions again for R2008a. Did you get the 2nd required download for R2008a and below?

  5. Q: I just downloaded the R2006a version for Windows. So where is mexnc.dll?

    A: As of R2006a, the new mex-file is called "mexnc.mexw32".

  6. Q: How can I test mexnc?

    A: There is a test suite contained in the "test" subdirectory underneath mexnc. But don't bother with this unless you are either source-compiling your own mex-file or are convinced that something is horribly wrong with your installation!

    If you absolutely must run the tests, make sure you follow the directions in the README in that subdirectory.

    The following command, though, is a real simple way of testing if the mex-file is completely wrong for you.

    >> mexnc ( 'STRERROR', 0 )
    
    If the result is not
    ans =
    
    No error
    
    
    then yes, you are right, something is horribly, horribly wrong.

  7. Q: I have a real ancient version of glibc, 2.2 or less. When I try to use mexnc on R14 linux x86, the first thing it says is something to the effect of
    ??? Invalid MEX-file '/path/to/mexnc/mexnc.mexglx': /lib/i686/libc.so.6: version `GLIBC_2.3' not found 
    (required by /path/to/mexnc/mexnc.mexglx).
    

    A: Check your version of glibc (especially if you are using a debian system). It would seem that mex-files compiled on versions of glibc greater than 2.3 won't work with systems with glibc 2.2 or less. This is a case where you end up having to compile your own mex-file. You should search out the section of the mexopts.sh file for CFLAGS that reads

    CFLAGS='-fPIC -ansi -D_GNU_SOURCE -pthread -fexceptions -m32'
    
    and get rid of the -m32 flag, which changes it to
    CFLAGS='-fPIC -ansi -D_GNU_SOURCE -pthread -fexceptions'
    
    MEXNC should now compile cleanly and run.

  8. Q: Why does the test suite fail on me?

    A: About the only good reason to run the test suite is if you are compiling your own version and want to contribute it back to me so I can post it for the benefit of others (in which case, thank you). Otherwise you really don't need to do that unless you suspect that there's a problem with your installation. Really.

    Ok, fine, don't listen to me. If you must plow foreward with this, make sure you read the instructions carefully and agree with the questions that the test suite asks you. And then, if it still doesn't work, email me.

  9. Q: Why do I get the following message everytime I use SNCTOOLS with java?
     ??? Error using ==> snctools\private\nc_info_java
    Could not open netCDF URL.
    

    A: Did you add the jar file to your path using javaaddpath? Check the README.

  10. What about the NetCDF Toolbox?

    It's completely unsupported. Use it at your own risk.

  11. Q: The following was seen on a Fedora Core 5 machine with R14 SP2 where mexnc was compiled with gcc 4.1. I'm using Matlab R14 SP2.
    ??? Invalid MEX-file '/home/jevans/matlab/mexcdf/mexnc/mexnc.mexglx': 
    /opt/matlabR14sp2/bin/glnx86/../../sys/os/glnx86/libgcc_s.so.1: 
    version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.6).
    

    A: You really shouldn't be seeing this anymore... but ...

    The problem is basically a mismatch between the version of gcc und the C++ libraries used to compile matlab, and the versions found the current system. According to Mathworks, we have

    So, you really should try to get yourself versions of gcc and libstdc++ that are as close as possible to these. Check with your friendly neighborhood sysadmin for details.

    Now suppose you have Mandriva 2007. Here are your options.

    Actually, I've never witnessed a problem with Mandriva and compiling mexnc, it's usually been Fedora Core or RedHat...

    The other trick to try is alluded to in the file ${MATLAB}/sys/os/glnx86/README.libstdc++, but you need to be the root user. Type these commands ...

    # cd $MATLAB
    # cd sys/os/glnx86
    # mkdir old
    # mv libstdc++.* libg2c.* libgcc_s* old
    
  12. When matlab is restarted, it will then use the system libraries instead of those supplied by Mathworks. And then all is fine and well with the world. Note that if this sort of thing happens with an x86-64 machine, then the directory in question would be ${MATLAB}/sys/os/glnxa64 instead of ${MATLAB}/sys/os/glnx86.