Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbol, nc_inq_var_fletcher32 whem importing netCDF4 #60

Closed
dopplershift opened this issue Feb 26, 2014 · 16 comments
Closed

Undefined symbol, nc_inq_var_fletcher32 whem importing netCDF4 #60

dopplershift opened this issue Feb 26, 2014 · 16 comments

Comments

@dopplershift
Copy link
Member

From deatho...@googlemail.com on July 20, 2010 11:32:34

Hi, I'm trying to import the netCDF4 module into a python script.

So far I have;
compiled the HDF5 library (v1.8.5).
configure --enable-hl --with-zlib=/usr/local
make check install

compiled the netCDF4 library linked against the HDF5 library (v4.0.1).
configure --enable-netcdf-4 --with-hdf5=/usr/local --with-zlib=/usr/local --prefix=/usr/local
make check install

then run the python netCDF4 installer.
python setup.py install

This all seems to work without an error message.

When I try importing the netCDF4 module;

import netDF4
Traceback (most recent call last):
File "", line 1, in
ImportError: /usr/lib/python2.6/site-packages/netCDF4.so: undefined symbol: nc_inq_var_fletcher32

Does anyone know what I'm doing wrong (I'm new to python).
Thanks

Original issue: http://code.google.com/p/netcdf4-python/issues/detail?id=60

@dopplershift
Copy link
Member Author

From deatho...@googlemail.com on July 20, 2010 10:34:36

Sorry, forgot to mention it's on an i686 running fedora 11

@dopplershift
Copy link
Member Author

From bast...@gmail.com on July 20, 2010 12:14:15

What did you compile with?

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on July 20, 2010 12:56:44

A missing symbol error like this usually means you linked a netcdf library that does not have netcdf-4 support. Since you indicated that you used --enable-netcdf-4 when building netcdf, it may be that there is another older version of the netcdf library on your system that the python build is picking up. Try "ldd /usr/lib/python2.6/site-packages/netCDF4.so" to see what netcdf library was actually linked. Another possibility is that the HDF5 headers and libs were not found by the netcdf-4 configure step, so it was built without netcdf-4 support. I would need to see the output of configure to know whether that is the case.

-Jeff

@dopplershift
Copy link
Member Author

From deatho...@googlemail.com on July 21, 2010 02:42:08

Thanks very much for your replies.

It was compiled with gcc and gfortran.

The netCDF4.so file links against

otus% ldd /usr/lib/python2.6/site-packages/netCDF4.so
linux-gate.so.1 => (0x007f4000)
libhdf5_hl.so.6 => /usr/local/lib/libhdf5_hl.so.6 (0x00a2f000)
libhdf5.so.6 => /usr/local/lib/libhdf5.so.6 (0x00d33000)
libz.so.1 => /lib/libz.so.1 (0x00b2d000)
libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00110000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00291000)
libc.so.6 => /lib/libc.so.6 (0x002ac000)
libm.so.6 => /lib/libm.so.6 (0x0041c000)
libdl.so.2 => /lib/libdl.so.2 (0x00444000)
libutil.so.1 => /lib/libutil.so.1 (0x00bf3000)
/lib/ld-linux.so.2 (0x00ae8000)

Which of those should I then be checking?

In the netcdf configure log, it refers to HDF5 a few times;

configure:3042: checking whether HDF5 should do data conversions
configure:3050: result: no
configure:3085: checking whether a location for the HDF5 library was specified
configure:3093: result: /usr/local
configure:3127: checking whether a default cache size for HDF5 was specified
configure:3137: result: 32000000
configure:3146: checking whether a default cache maximum number of elements for HDF5 was specified
configure:3156: result: 1000
configure:3165: checking whether a default cache preemption for HDF5 was specified
configure:3175: result: 0.75
| #define HAVE_HDF5_H 1
| #define HAVE_LIBHDF5 1
| #define HAVE_LIBHDF5_HL 1
HDF5DIR='/usr/local'
USE_HDF5_DIR_FALSE='#'
USE_HDF5_DIR_TRUE=''

I'm afraid I don;t understand what those last two lines mean. Does a "#" mean that it's not false, or that it is false?

Thanks again

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on July 21, 2010 05:16:02

Looks like netcdf was compiled statically, so ldd doesn't show you the path. Try running "nm -p /usr/local/lib/libnetcdf.a | grep nc_inq_var_fletcher32". That will tell you if the symbol is in there. If it isn't, try re-running the configure step for the netcdf lib, saving it to a file. Then post the file as an attachment. Also post the output of "python setup.py build".

Note that netcdf 4.1.1 is required - you appear to be using 4.0.1

-Jeff

@dopplershift
Copy link
Member Author

From deatho...@googlemail.com on July 21, 2010 05:21:37

Thanks again

The search gave;

otus% nm -p /usr/local/lib/libnetcdf.a | grep nc_inq_var_fletcher32
00003cc0 T nc_inq_var_fletcher32
U nc_inq_var_fletcher32

which I suppose means it's in there.

The configure file used for this compilation is attached.

Thanks very much again
Steve

Attachment: config.log

@dopplershift
Copy link
Member Author

From deatho...@googlemail.com on July 21, 2010 05:23:59

The output of python setup.py build

[root@otus netCDF4-0.9.1]# python setup.py build
None
None

HDF5_DIR environment variable not set, checking some standard locations ..,
checking /root ...
checking /usr/local ...
HDF5 found in /usr/local

NETCDF4_DIR environment variable not set, checking some standard locations ..,
checking /root ...
checking /usr/local ...
netCDF4 found in /usr/local
/usr/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'summary'
warnings.warn(msg)
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
building py_modules sources
building extension "netCDF4" sources
running build_py
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
running scons
running build_scripts

Thanks

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on July 21, 2010 06:04:14

You have to remove the build directory before running setup.py, otherwise it doesn't recompile.

@dopplershift
Copy link
Member Author

From deatho...@googlemail.com on July 21, 2010 06:07:17

Thanks. Just compiling version 4.1.1 of netcdf now, I'll have a go at that.

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on July 21, 2010 06:09:52

I was asking for you to save the output of running the configure script, not the config.log file, for example

./configure <configure options 1> configure.log 2> configure.log

or with csh

./configure &! configure.log

Since the missing symbol appears to be in the library, I suspect you are actually linking another version of the library on your system somewhere when you run setup.py.

-Jeff

@dopplershift
Copy link
Member Author

From deatho...@googlemail.com on July 21, 2010 06:13:12

Ah, sorry. I'll have another go as soon as the compilation's finished.

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on July 21, 2010 06:57:20

OK, but from your config.log I doubt that your build is the problem. You do need to use 4.1.1 though, not 4.0.1. While you are rebuilding, please use --enable-shared, that way ldd will reveal if you have linked the correct library. Do you by any chance have a libnetcdf.a in /usr/lib?

@dopplershift
Copy link
Member Author

From deatho...@googlemail.com on July 21, 2010 08:30:22

Thanks very much for your help, I've compiled the netcdf-4.1.1 library and that seems to work. I can now import the netCDF4 module in to python.

I have a libnetcdf.a in /usr/local/lib

Steve

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on July 21, 2010 08:37:43

Great - let me know if you have any other issues.

-Jeff

Status: Invalid

@dopplershift
Copy link
Member Author

From jakobru...@gmail.com on December 11, 2010 12:22:53

I have the same problem, but unresolved...

I built netcdf-4.1.1 with
./configure --with-hdf5=/usr/local --prefix=/usr/local
make check install

Then (atfer removing build) ran:
python setup.py install and got through with output

HDF5_DIR environment variable not set, checking some standard locations ..,
checking /home/jakob ...
checking /usr/local ...
HDF5 found in /usr/local

NETCDF4_DIR environment variable not set, checking some standard locations ..,
checking /home/jakob ...
checking /usr/local ...
netCDF4 found in /usr/local
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
building py_modules sources
building extension "netCDF4" sources
running build_py
creating build
creating build/lib.linux-i686-2.6
copying netCDF4_utils.py -> build/lib.linux-i686-2.6
creating build/lib.linux-i686-2.6/netcdftime
copying netcdftime/netcdftime.py -> build/lib.linux-i686-2.6/netcdftime
copying netcdftime/init.py -> build/lib.linux-i686-2.6/netcdftime
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
building 'netCDF4' extension
compiling C sources
C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC

creating build/temp.linux-i686-2.6
compile options: '-I/usr/local/include -I/usr/local/include -I/usr/lib/python2.6/dist-packages/numpy/core/include -I/usr/include/python2.6 -c'
gcc: netCDF4.c
netCDF4.c: In function ‘__pyx_pf_7netCDF4_getlibversion’:
netCDF4.c:25841: warning: assignment discards qualifiers from pointer target type
netCDF4.c: In function ‘__pyx_f_7netCDF4__find_cmptype’:
netCDF4.c:22920: warning: ‘__pyx_v_xtype’ may be used uninitialized in this function
netCDF4.c: In function ‘__pyx_pf_7netCDF4_8Variable_chunking’:
netCDF4.c:14478: warning: ‘__pyx_v_ndims’ may be used uninitialized in this function
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-i686-2.6/netCDF4.o -L/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -Wl,-R/usr/local/lib -lnetcdf -lhdf5_hl -lhdf5 -lz -o build/lib.linux-i686-2.6/netCDF4.so
running scons
running build_scripts
creating build/scripts.linux-i686-2.6
copying utils/nc3tonc4 -> build/scripts.linux-i686-2.6
copying and adjusting utils/nc4tonc3 -> build/scripts.linux-i686-2.6
copying and adjusting utils/grib2nc4 -> build/scripts.linux-i686-2.6
changing mode of build/scripts.linux-i686-2.6/nc4tonc3 from 644 to 755
changing mode of build/scripts.linux-i686-2.6/grib2nc4 from 644 to 755
running install_lib
copying build/lib.linux-i686-2.6/netCDF4.so -> /usr/local/lib/python2.6/dist-packages
running install_scripts
copying build/scripts.linux-i686-2.6/nc4tonc3 -> /usr/local/bin
copying build/scripts.linux-i686-2.6/grib2nc4 -> /usr/local/bin
changing mode of /usr/local/bin/nc3tonc4 to 755
changing mode of /usr/local/bin/nc4tonc3 to 755
changing mode of /usr/local/bin/grib2nc4 to 755
running install_egg_info
Removing /usr/local/lib/python2.6/dist-packages/netCDF4-0.9.3.egg-info
Writing /usr/local/lib/python2.6/dist-packages/netCDF4-0.9.3.egg-info

But when testing I get:

$ python run_all.py
Traceback (most recent call last):
File "run_all.py", line 1, in
import glob, os, sys, unittest, netCDF4
ImportError: /usr/local/lib/python2.6/dist-packages/netCDF4.so: undefined symbol: nc_set_var_chunk_cache

Any solution?

Thanks,
Jakob

@dopplershift
Copy link
Member Author

From whitaker.jeffrey@gmail.com on December 11, 2010 13:16:46

Jakub: You need to build netcdf with --enable-netcdf-4 --enable-shared (and --enable-dap if you want opendap support).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant