PnetCDF question?

Wei-keng Liao wkliao at eecs.northwestern.edu
Thu Mar 3 10:27:55 CST 2016


Hi Yao,

If you are using GNU based MPI compiler, please try rebuild pnetcdf to a static library,
i.e. without using -fPIC, and then add the following to your ESMF link command line.

   -Wl,-Bstatic -lpnetcdf


Wei-keng

On Mar 3, 2016, at 10:15 AM, Hu, Yao wrote:

> Hi Wei-keng,
> 
> Thank you for your response. I tried the setting you described. It still generates a new libpnetcdf.a under /usr/local/lib. I thus cannot link ESMF with libpnetcdf.a dynamically when I want to compile and build ESMF using the makefile. Is there a way to generate a shared library for the parallel netcdf? 
> 
> Thanks,
> Yao 
> 
> Yao Hu, PhD
> Postdoctoral Researcher
> National Center for Supercomputing Applications
> 1205 W Clark St.
> Urbana, IL, USA 61801
> 
> ________________________________________
> From: Wei-keng Liao [wkliao at eecs.northwestern.edu]
> Sent: Wednesday, March 02, 2016 6:09 PM
> To: Hu, Yao
> Cc: parallel-netcdf at mcs.anl.gov
> Subject: Re: PnetCDF question?
> 
> Hi, Yao
> 
> Please try setting CFLAGS when rebuilding PnetCDF, i.e.
> export CFLAGS="-fPIC"
> 
> Check the time stamp of libpnetcdf.a under /usr/local/lib
> to make sure that is the one you built and installed.
> 
> 
> Wei-keng
> 
> On Mar 2, 2016, at 4:59 PM, Hu, Yao wrote:
> 
>> 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