Closed afernandezody closed 4 years ago
Which version of PnetCDF are you using? (or cloned from this repo?)
Please provide file "config.log" which was generated after running your command 'configure' (./configure --prefix=/opt/netcdf --enable-shared). It may reveal some information.
Hi @wkliao, Yes, it's cloned. The compilation failed on Monday twice so I just built it as a static library (this wasn't the 1st time that I ran into that error). Unfortunately, I forgot to save the config.log as I was rushing to have a workable library. Since then, I have tried the configuration 3 times in other systems with different OSs but the error doesn't reproduce. I'm still investigating which system or configuration parameter triggers the error. Thanks.
I was finally able to fix the issue (when it appears) by adding -fPIC to the linker flags. Thanks.
Just to clarify this issue. One should not need to add -fPIC to the linker flags in order to build a shared library. PnetCDF uses libtool which automatically sets the necessary compile and link flags. In most of the cases, -fPIC is added automatically when configure option --enable-shared is used.
The below extracted error messages you are getting is most likely because the MPI compilers are not built with shared libraries enabled. PnetCDF checks this possibility at configure time, which is why I asked for file 'config.log' and hope it can reveal such information.
/usr/bin/ld: .libs/libpnetcdf.lax/libf77.a/strerrnof.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: .libs/libpnetcdf.lax/libf90.a/pnetcdf.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
If you would like to try it again, I am interested to learn how it goes. Please run commands below to have a clean build.
make distclean
./configure --prefix=/opt/netcdf --enable-shared
make
I'm also interested in understanding why it fails sometimes. I don't disagree with what you're saying about libtool but what do you mean by the MPI compilers are not built with shared libraries enabled? My interpretation is that you're referring to the MPI wrapper (not the compilers used to build it) but (I think that) OpenMPI builds with shared libraries enabled by default. Other apps compile and build their shared libraries w/o complaining; one exception was the compilation of netcdf-fortran with cmake when I had to use the -fPIC flag.
Yes, what I meant for the "MPI compilers" are the MPI wrappers, such as mpicc, mpifort, etc. Another possibility is you first configured PnetCDF using one set of MPI compilers and then used a different set of MPI compilers to run 'make' (such as different versions of OpenMPI or mixed use of OpenMPI and MPICH, or the environmental variable PATH is changed in between configure and make.)
Without the file 'config.log', all I can do is guessing. If you encountered the same failure again, please provide that log file.
Hello, The compilation for shared libraries is failing (./configure --prefix=/opt/netcdf --enable-shared) with the message:
I tried adding -fPIC to CCFLAGS & CXXFLAGS but it didn't make any difference. Thanks.