j-m-adams / GrADS

The Grid Analysis and Display System (GrADS)
Other
19 stars 10 forks source link

Ubuntu 18.04 Makefile problem and gradspy undefined symbol #7

Open woodbri opened 3 years ago

woodbri commented 3 years ago

Look like I've run into two issues with building on Ubuntu 18.04. 1) It looks like the Makefile linking the grads command is failing to add -ludunits2

PKG_CONFIG=/usr/bin/pkg-config ./configure --prefix=/usr/local \
--with-hdf5-include=/usr/include/hdf5/serial \
--with-hdf5-libdir=/usr/lib/x86_64-linux-gnu \
--with-netcdf-include=/usr/include \
--with-netcdf-libdir=/usr/lib/x86_64-linux-gnu \
--with-hdf4-include=/usr/include/hdf \
--with-hdf4-libdir=/usr/lib \
--with-udunits2-include=/usr/lib \
--with-udunits2-libdir=/usr/lib/x86_64-linux-gnu

# works ok but make fails like this:

gcc   -g -O2 -rdynamic   -o grads grads.o gxsubs.o gxmeta.o gxchpl.o gxcntr.o gxstrm.o gxdb.o gxwmap.o gxshad.o gxshad2.o gaexpr.o gafunc.o gautil.o gagx.o gscrpt.o gamach.o gatxt.o galloc.o gaddes.o gacfg.o gaio.o gauser.o gasdf.o bufrstn.o gabufr.o gabufrtbl.o   -L..//lib      -lreadline -lgrib2c -ljasper -lpng15 -lz  -lhdf5 -ljpeg -lz  -lnetcdf  -lgeotiff -ltiff  -lshp    -ldl  -lm
gasdf.o: In function `initUnitSys':
/home/woodbri/work/GrADS-jam/src/gasdf.c:273: undefined reference to `ut_ignore'
/home/woodbri/work/GrADS-jam/src/gasdf.c:273: undefined reference to `ut_set_error_message_handler'
/home/woodbri/work/GrADS-jam/src/gasdf.c:276: undefined reference to `ut_read_xml'
/home/woodbri/work/GrADS-jam/src/gasdf.c:281: undefined reference to `ut_get_unit_by_name'
/home/woodbri/work/GrADS-jam/src/gasdf.c:285: undefined reference to `ut_get_unit_by_name'
/home/woodbri/work/GrADS-jam/src/gasdf.c:289: undefined reference to `ut_get_unit_by_name'
/home/woodbri/work/GrADS-jam/src/gasdf.c:293: undefined reference to `ut_get_unit_by_name'
gasdf.o: In function `compare_units':
/home/woodbri/work/GrADS-jam/src/gasdf.c:1472: undefined reference to `ut_trim'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1475: undefined reference to `ut_parse'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1476: undefined reference to `ut_parse'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1503: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1482: undefined reference to `ut_are_convertible'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1502: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1503: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1502: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1483: undefined reference to `ut_get_converter'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1487: undefined reference to `cv_convert_double'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1488: undefined reference to `cv_convert_double'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1502: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1503: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:1504: undefined reference to `cv_free'
gasdf.o: In function `findZ':
/home/woodbri/work/GrADS-jam/src/gasdf.c:2065: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2020: undefined reference to `ut_parse'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2022: undefined reference to `ut_are_convertible'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2029: undefined reference to `ut_are_convertible'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2037: undefined reference to `ut_are_convertible'
gasdf.o: In function `findT':
/home/woodbri/work/GrADS-jam/src/gasdf.c:2136: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2137: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2105: undefined reference to `ut_parse'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2106: undefined reference to `ut_encode_time'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2106: undefined reference to `ut_offset_by_time'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2109: undefined reference to `ut_are_convertible'
gasdf.o: In function `set_time_type':
/home/woodbri/work/GrADS-jam/src/gasdf.c:2595: undefined reference to `ut_parse'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2597: undefined reference to `ut_encode_time'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2597: undefined reference to `ut_offset_by_time'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2598: undefined reference to `ut_are_convertible'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2602: undefined reference to `ut_free'
/home/woodbri/work/GrADS-jam/src/gasdf.c:2603: undefined reference to `ut_free'
gasdf.o: In function `gadsdf':
/home/woodbri/work/GrADS-jam/src/gasdf.c:880: undefined reference to `ut_parse'
/home/woodbri/work/GrADS-jam/src/gasdf.c:889: undefined reference to `ut_encode_time'
/home/woodbri/work/GrADS-jam/src/gasdf.c:889: undefined reference to `ut_offset_by_time'
/home/woodbri/work/GrADS-jam/src/gasdf.c:892: undefined reference to `ut_are_convertible'
/home/woodbri/work/GrADS-jam/src/gasdf.c:894: undefined reference to `ut_get_converter'
/home/woodbri/work/GrADS-jam/src/gasdf.c:896: undefined reference to `cv_convert_double'
/home/woodbri/work/GrADS-jam/src/gasdf.c:898: undefined reference to `ut_decode_time'
/home/woodbri/work/GrADS-jam/src/gasdf.c:899: undefined reference to `cv_free'
collect2: error: ld returned 1 exit status
Makefile:771: recipe for target 'grads' failed
make[2]: *** [grads] Error 1
make[2]: Leaving directory '/data/work/GrADS-jam/src'
Makefile:614: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/data/work/GrADS-jam/src'
Makefile:462: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

but linking like this works by manually adding -ludunits2 to the link command

cd src
gcc   -g -O2 -rdynamic   -o grads grads.o gxsubs.o gxmeta.o gxchpl.o gxcntr.o gxstrm.o gxdb.o gxwmap.o gxshad.o gxshad2.o gaexpr.o gafunc.o gautil.o gagx.o gscrpt.o gamach.o gatxt.o galloc.o gaddes.o gacfg.o gaio.o gauser.o gasdf.o bufrstn.o gabufr.o gabufrtbl.o   -L..//lib      -lreadline -lgrib2c -ljasper -lpng15 -lz  -lhdf5 -ljpeg -lz  -lnetcdf  -lgeotiff -ltiff  -lshp  -ludunits2  -ldl  -lm

cd ..
make  # finishes without any additional errors

notice the manual inclusion of '-ludunits2' to get it to link,

  1. but gradspy fails with undefined symbol below:
sudo make install
cd src
sudo python3 setup.py install

python3
Python 3.6.9 (default, Oct  8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gradspy
/usr/local/lib/libgradspy.so: undefined symbol: ut_ignore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: initialization of gradspy failed without raising an exception
woodbri commented 3 years ago

I don't know if this helps but some more info:

woodbri@B1B8B6F:~/work/GrADS-jam/src$ ldconfig -p  | grep units
        libudunits2.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libudunits2.so.0
        libudunits2.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libudunits2.so

woodbri@B1B8B6F:~/work/GrADS-jam/src$ nm /usr/local/lib/libgradspy.so | grep ' ut_'
00000000000b0a63 T ut_create_buffer
00000000000b09a3 T ut_delete_buffer
00000000000b09d9 T ut_flush_buffer
00000000000b0a1d T ut_init_buffer
00000000000b0919 T ut_load_buffer_state
00000000000b16d9 T ut_scan_buffer
00000000000b177b T ut_scan_bytes
00000000000b17f0 T ut_scan_string
00000000000b0955 T ut_switch_to_buffer

woodbri@B1B8B6F:~/work/GrADS-jam/src$ grep ut_ignore *
grep: build: Is a directory
gasdf.c:      ut_set_error_message_handler(ut_ignore);
Binary file gasdf.o matches
Binary file grads matches