NetCDF-4.0.1 shared library

How do you build the Netcdf shared library using pgi 7.1-4?

./configure --enable-shared LDFLAGS=“-L/usr/lib64/ -L/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/lib” CC=“gcc” CXX=“gcc” CXXCPP=‘gcc -E’ F77=‘pgf90 -fpic’ FC=‘pgf90 -fpic’ --with-pic

/usr/local/bin/ld: /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/lib/libpgf90.a(allo.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC

Hi sriki,

Use the “libso” directory for the dynamic libraries. “lib” contains the static libraries.

./configure --enable-shared LDFLAGS="-L/usr/lib64/ -L/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso" CC="gcc" CXX="gcc" CXXCPP='gcc -E' F77='pgf90 -fpic' FC='pgf90 -fpic' --with-pic

Hope this helps,
Mat

./configure --enable-shared LDFLAGS=“-L/usr/lib64/ -L/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso” CC=“gcc” CXX=“gcc” CXXCPP=‘gcc -E’ F77=‘pgf90 -fpic’ FC=‘pgf90 -fpic’ --with-pic
configure: netCDF 4.0.1
checking build system type… x86_64-unknown-linux-gnu
checking host system type… x86_64-unknown-linux-gnu
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
configure: checking user options
checking whether CXX is set to ‘’… no
checking whether FC is set to ‘’… no
checking whether F90 is set to ‘’… no
checking whether a NCIO_MINBLOCKSIZE was specified… 256
checking whether this is a netCDF-4.x build… yes
checking whether extra valgrind tests should be run… no
configure: Processing NetCDF-4 options.
checking whether netCDF-4 is to be built… no
checking whether new netCDF-4 C++ API is to be built… no
checking whether HDF5 should do data conversions… no
checking whether extra example tests should be run… no
checking whether parallel IO tests should be run… no
checking whether a location for the HDF5 library was specified…
checking whether a location for the ZLIB library was specified…
checking whether a location for the SZLIB library was specified…
checking whether a default cache size for HDF5 was specified… 32000000
checking whether a default cache maximum number of elements for HDF5 was specified… 1000
checking whether a default cache preemption for HDF5 was specified… 0.75
checking whether netCDF-4 logging is enabled… no
checking whether DAP client is to be built… no
checking whether dap remote testing should be enabled… no
checking whether netCDF extra tests should be run (developers only)… no
checking whether documentation is to be installed… no
checking whether Fortran compiler(s) should be tested during configure… yes
checking whether FFIO will be used… no
checking whether to skip C++, F77, or F90 APIs if compiler is broken… yes
checking whether only the C library is desired… no
checking whether examples should be built… yes
checking whether F77 API is desired… yes
checking whether F90 API is desired… yes
checking whether fortran type sizes should be checked… yes
checking whether C API is desired… yes
checking where to get netCDF C-only library for separate fortran libraries…
checking whether CXX API is desired… yes
checking whether v2 netCDF API should be built… yes
checking whether the ncgen/ncdump should be built… yes
checking whether large file (> 2GB) tests should be run… no
checking whether benchmaks should be run (experimental)… no
checking whether extreme numbers should be used in tests… yes
checking where to put large temp files if large file tests are run… .
checking whether a win32 DLL is desired… no
checking whether separate fortran libs are desired… yes
configure: finding C compiler
checking for C compiler default output file name…
configure: error: C compiler cannot create executables
See `config.log’ for more details.


I get the same error with CC=pgcc.

g++ isinstalled

more test1.c
int
main ()
{

;
return 0;
}
g++ test1.c
works fine

Thanks for your help

Hi sriki,

My best guess is that the configure script isn’t taking the “CC” option from the command line so is using “cc” as the compiler.

Try setting the CC=“gcc” CXX=“gcc” CXXCPP=‘gcc -E’ F77=‘pgf90 -fpic’ FC=‘pgf90 -fpic’ variables in your shell’s environment and then run configure.

If this doesn’t work, what’s the exact error shown in “config.log” as to why this basic C file can’t be compiled?

  • Mat

pgcc 7.1-4 64-bit target on x86-64 Linux -tp p7-64
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
configure:4008: $? = 0
configure:4031: checking for C compiler default output file name
configure:4053: /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/bin/pgcc -o2 -Msignextend -V -DNDEBUG -DpgiFortran -L/usr/lib64/ -L/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso conftest.c -L/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso -lpgf90 -lpgf90rtl -lpgftnrtl -lm -lpthread >&5
conftest.c:
PGC/x86-64 Linux 7.1-4
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_chn_1toN' /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_endpar’
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_bcopy' /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_stat_recv_done’
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_true_log4' /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_one’
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_barrier' /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_trac_line_entry’
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_zed' /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_trac_await’
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_par_close' /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_prof_init’
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_init_consts' /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to _hpfio_cnfg
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpf_maxs' /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90.so: undefined reference to __hpfio_scratch_name’


Thanks, Mat

Hi sriki,

The error is because the library “-lpgf902” is missing from the link. Why, I’m not sure. You can try adding it to your LDFLAGS, but this would just be a work around.

From a fresh install and environment, can you please post the exact steps you did to get this error? I tried to recreate the error here using NetCDF 4.0 and PGI 7.1-4 but was unable (It just worked for me).

Thanks,
Mat

Mat,

Here are my settings…

setenv CC /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/bin/pgcc
setenv FC /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/bin/pgf90
setenv F90 /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/bin/pgf90
setenv CXX /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/bin/pgCC
setenv CFLAGS “-o2 -Msignextend -V”
setenv CPPFLAGS “-DNDEBUG -DpgiFortran”
setenv FFLAGS “-o2 -w -V”
setenv F90FLAGS -g
setenv CXXFLAGS -g
setenv F77 /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/bin/pgf77

./configure --enable-shared LIBS=“-L/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso -lpgc -lpgf90_rpm1 -lpgf902 -lpghpf -lpghpf2 -lpgf90rtl -lpgftnrtl -lm -lpthread -lrt”

Here’s the config.log output…

pgcc 7.1-4 64-bit target on x86-64 Linux -tp p7-64
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
configure:4008: $? = 0
configure:4031: checking for C compiler default output file name
configure:4053: /usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/bin/pgcc -o2 -Msignextend -V -DNDEBUG -DpgiFortran conftest.c -L/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso -lpgc -lpgf90_rpm1 -lpgf902 -lpghpf -lpghpf2 -lpgf90rtl -lpgftnrtl -lm -lpthread -lrt >&5
conftest.c:
PGC/x86-64 Linux 7.1-4
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso/libpgf90rtl.so: undefined reference to `pgf90_compiled’

pgcc 7.1-4 64-bit target on x86-64 Linux -tp p7-64
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
configure:4057: $? = 2
configure:4095: result:
configure: failed program was:
| /* confdefs.h. /
| #define PACKAGE_NAME “netCDF”
| #define PACKAGE_TARNAME “netcdf”
| #define PACKAGE_VERSION “4.0.1”
| #define PACKAGE_STRING “netCDF 4.0.1”
| #define PACKAGE_BUGREPORT “support@unidata.ucar.edu
| #define PACKAGE “netcdf”
| #define VERSION “4.0.1”
| #define NCIO_MINBLOCKSIZE 256
| #define CHUNK_CACHE_SIZE 32000000
| #define CHUNK_CACHE_NELEMS 1000
| #define CHUNK_CACHE_PREEMPTION 0.75
| #define USE_EXTREME_NUMBERS 1
| #define TEMP_LARGE “.”
| /
end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:4102: error: C compiler cannot create executables






Jayanthi

Hi Jayanthi,

This particular problem is due to library ordering. You can try using the flag “-pgf90libs” instead of listing out the libraries, (-pgf90libs will add the correct F90 libraries in the correct order), but I would simply run configure without any added libraries.

I think you have two main issues. One is that you’re using “-o2” not “-O2”. “-o” tells the compiler the name of the output file while “-O2” is an optimization flag. Please change your “CFLAGS” to “-O2 -Msignextend -V” and “FFLAGS” to “-O2 -w -V”

Secondly, you’re most likely not setting “LD_LIBRARY_PATH” to “/usr/local/tools/pgi-7.1-4/linux86-64/7.1-4/libso” in your environment. Without this set, the loader is unable to find the shared libraries.

Hope this helps,
Mat

Mat,

Thanks for your help!