PnetCDF question?

Hu, Yao yaohu2 at illinois.edu
Wed Mar 2 16:59:57 CST 2016


Hi Rob,

Thank you for your clarification. 

Sorry, I don't understand when you say

"But, with -fPIC you have now provided enough additional information for
your linker to hook everything together. "

How I can info ESMF the path to libpnetcdf.a dynamically?

Here, I set tags in ESMF makefile (http://www.earthsystemmodeling.org/esmf_releases/public/last/ESMF_usrdoc/node9.html)

ESMF_PNETCDF:           standard
ESMF_PNETCDF_INCLUDE:   /usr/local/include    
ESMF_PNETCDF_LIBS:      -lpnetcdf
ESMF_PNETCDF_LIBPATH:   /usr/local/lib            (# the directory for the libpnetcdf.a)

After run make, I then get the same error:

/usr/bin/ld: /usr/local/lib/libpnetcdf.a(strerrorf.o): relocation R_X86_64_PC32 against undefined symbol `__stack_chk_fail@@GLIBC_2.4' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

Sorry, I am quite new to Linux.

Thanks,
Yao


Yao Hu, PhD
Postdoctoral Researcher
National Center for Supercomputing Applications
1205 W Clark St.
Urbana, IL, USA 61801

________________________________________
From: Latham, Robert J. [robl at mcs.anl.gov]
Sent: Wednesday, March 02, 2016 4:20 PM
To: Hu, Yao
Cc: parallel-netcdf at mcs.anl.gov
Subject: Re: PnetCDF question?

On Wed, 2016-03-02 at 22:04 +0000, Hu, Yao wrote:

> I understand the libpnetcdf.a is a static library and cannot be dynamically linked with. I thus tried to add the flag:
>

Let me clarify slightly: the static library can be part of a shared
library build.  It's just that the pnetcdf parts will be statically
linked.  Look at the pnetcdf utilities:

% ldd ~/work/soft/pnetcdf/bin/ncmpigen
        linux-vdso.so.1 =>  (0x00007ffc231ee000)
        libmpi.so.0 => /home/robl/work/soft/mpich-clang/lib/libmpi.so.0
(0x00007f4e581aa000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4e57de5000)
        libpmpi.so.0 => /home/robl/work/soft/mpich-clang/lib/libpmpi.so.0
(0x00007f4e577d9000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f4e575d1000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f4e573b3000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f4e5854c000)


They use both shared and static libraries.

> export CXXFLAGS="$CXXFLAGS -fPIC"
>
> before I configure parallel netcdf. Unfortunately, it still generates the static (.a) library. Could you please let me know how to generate the dynamically linked library (.os)? or other suggestions? Thanks in advance.
>

Yep, you'll get a (slightly larger) libpnetcdf.a with the -fPIC flag.
But, with -fPIC you have now provided enough additional information for
your linker to hook everything together.

==rob

> Sincerely,
> Yao
>
> Yao Hu, PhD
> Postdoctoral Researcher
> National Center for Supercomputing Applications
> 1205 W Clark St.
> Urbana, IL, USA 61801




More information about the parallel-netcdf mailing list