Page tree

GRIB-API support is being discontinued at the end of 2018. Please consider upgrading to ecCodes


Skip to end of metadata
Go to start of metadata

How do I install with CMake?

See GRIB API CMake installation

Getting an "relocation R_X86_64_32 against `.bss' cannot be used when making a shared object; recompile with -fPIC"

Like for example the following case

/usr/bin/ld: /usr/local/lib/libjasper.a(jas_image.o): relocation R_X86_64_32 against `.bss' cannot be used when making a shared object; recompile with -fPIC
/usr/local/lib/libjasper.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make1: *** libgrib_api.la Error 1
make1: Leaving directory `src'
make: *** install-recursive Error 1

A jasper library that has been linked statically is trying to be linked into a dynamic libgrib_api.so. Libraries linked to a dynamic library must use "relocatable" code, and normally static libraries aren't. Possible solutions are:

  • If possible, use a dynamic version of jasper. Build it with support for static libraries. Most rpm or deb packages already include a dynamic version that will be taken in preference. Or
  • Build jasper with the "-fPIC" CFLAG. In that case even the static library will be relocatable.
  • Use the "--disable-shared" option in grib_api. In this case no dynamic library will be produced (just the static version) and the problem won't be applicable any more.

Get "duplicated symbol" errors in Mac OS X Lion (10.7)

This problem may happen when using the libtool version of grib_api

ld: duplicate symbol _grib_file_not_found in .libs/action_class_alias.o and .libs/action.o for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [libgrib_api.la] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

The reason of this error is the inclusion of the "-fno_common" flag in the compilation of the object files (eg .libs/action_class_alias.o) which is added by autotools. From the Apple gcc man page:

      -fno-common
           In C, allocate even uninitialized global variables in the data
           section of the object file, rather than generating them as common
           blocks.  This has the effect that if the same variable is declared
           (without "extern") in two different compilations, you will get an
           error when you link them.  The only reason this might be useful is
           if you wish to verify that the program will work on other systems
           which always work this way.

The workaround is to edit the "configure" file and remove -fno-common from the added flags. It should be possible to edit the libtool.m4 file to remove the extra flag too. This way the flag wouldn't have to be removed manually whenever configure.ac changes.

Installing architecture independent files under a different prefix

For some installations you may want to install architecture or compiler dependent files, like executables, libraries and Fortran mod files in one area, while keeping a shared installation of the architecture independent files, like GRIB definitions, templates and samples. This can be achieved by using some autotools features.

$ ./configure --prefix=/usr/ --datarootdir=/data/share; make; make install

With these commands architecture dependent files will go to /usr/bin and /usr/lib and architecture independent files to /data/share/grib_api/. It is also possible to only install binaries or definitions by executing "make install" in a subdirectory, as opposed to at the top level. For example:

$ ./configure --prefix=/usr/ --datarootdir=/data/share; make; make check

$ # Installing only libs and tools under /usr
$ cd src; make install; cd ..
$ cd tools; make install; cd ..

$ # Installing only definitions and samples under /data/share/grib_api
$ cd definitions; make install; cd ..
$ cd samples; make install; cd ..

Error testing in SPARC architectures (Solaris or Debian): Creating ()_xxx of section at offset xxx over message boundary

grib_api must be installed with the "--enable-memory-align" option in SPARC architectures. Otherwise the result is this error. Do make sure to run "make clean" before running "configure" again

$ make clean
$ ./configure .... --enable-align-memory
$ make 
$ make check    # Always run 'make check' to ensure your compilation results are correct

If the option is not used, you will get errors similar to the following

Invalid grib message(s) found in data/out.grib2
FAIL: convert.sh
TEST: ./filter.sh
GRIB_API ERROR   :  Message is too large for the current architecture
FAIL: filter.sh
TEST: ./multi.sh
GRIB_API ERROR   :  Creating ()_if17b118 of section at offset 7494-7494 over message boundary (3747)
GRIB_API ERROR   :  Creating ()_if17b118 of section at offset 119278-119278 over message boundary (59639)
GRIB_API ERROR   :  Creating ()_if17b118 of section at offset 193150-193150 over message boundary (96575)
  • No labels

1 Comment

  1. It's advisable to do a 'make clean' after editing the 'configure' file.