compiling problem with netcdf

Hi everyone

I am a newbie in programming. I just met some compiling problem with my project

The error msg is

ar: creating Build/libUTIL.a
ranlib Build/libUTIL.a
master.f90:
/usr/local/mpi/bin/mpif90 -O3 Build/esmf_roms.o Build/master.o Build/ocean_control.o Build/ocean_coupler.o Build/propagator.o Build/roms_export.o Build/roms_import.o -o oceanM Build/libNLM.a Build/libNLM_bio.a Build/libNLM_sed.a Build/libANA.a Build/libUTIL.a Build/libMODS.a -L/usr/netcdf-3.6.0-p1/lib -lnetcdf
/usr/local/mvapich/lib/libmpichf90nc.a: file not recognized: File format not recognized

Could anyone help me out?

Thanks in advance

Yisen

I then changed the flag from -03 to -Bstatic -fastsse -Mipa=fast
and I got such error

/usr/local/mpi/bin/mpif90 -Bstatic -fastsse -Mipa=fast Build/esmf_roms.o Build/master.o Build/ocean_control.o Build/ocean_coupler.o Build/propagator.o Build/roms_export.o Build/roms_import.o -o oceanM Build/libNLM.a Build/libNLM_bio.a Build/libNLM_sed.a Build/libANA.a Build/libUTIL.a Build/libMODS.a -L/usr/netcdf-3.6.0-p1/lib -lnetcdf
IPA: no IPA optimizations for 5 source files
IPA: Recompiling Build/master.o: new IPA information
master.f90:
IPA: Recompiling Build/ocean_control.o: new IPA information
ocean_control.f90:
/usr/local/mvapich/lib/libmpich.a(viainit.o): In function get_host_id': viainit.c:(.text+0x19ad): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/local/ofed/lib64/libibverbs.a(src_libibverbs_la-init.o): In function load_driver’:
src/init.c:66: undefined reference to dlopen' src/init.c:73: undefined reference to dlerror’
src/init.c:74: undefined reference to dlsym' src/init.c:75: undefined reference to dlerror’
src/init.c:68: undefined reference to dlerror' /usr/local/ofed/lib64/libibverbs.a(src_libibverbs_la-init.o): In function ibverbs_init’:
src/init.c:232: undefined reference to sysfs_open_class' src/init.c:241: undefined reference to sysfs_get_class_devices’
src/init.c:247: undefined reference to dlist_start' src/init.c:247: undefined reference to _dlist_mark_move’
/usr/local/ofed/lib64/libibverbs.a(src_libibverbs_la-init.o): In function init_drivers': src/init.c:137: undefined reference to sysfs_open_class_device’
/usr/local/ofed/lib64/libibverbs.a(src_libibverbs_la-init.o): In function ibverbs_init': src/init.c:247: undefined reference to _dlist_mark_move’
/usr/local/ofed/lib64/libibverbs.a(src_libibverbs_la-init.o): In function load_driver': src/init.c:83: undefined reference to dlclose’
child process exit status 1: /usr/bin/ld

I really have no idea what is going on at all.
I’d appreciate any suggestion

OK the unresolved symbols dlopen, dlerror, dlsym, etc. are for dynamic loading, and they usually are resolved when you pass the linker the flag

-ldl

referring to libdl.so

These functions are used by programs to perform dynamic loading - that is they can load functions while the program is running.

The -Bstatic flag relates to this, but in a way which depends on the linker. It is sort of the opposite of dynamic loading, it says that shared objects are statically linked to the executable.

However that does not get rid of any code in the program that could call the functions of libdl. So you might need the -ldl flag.

Disclaimer: What details I know about this relate to versions of things from about 15 years ago, so things may have changed a lot.

Hi Yisen,

The second issue is due to your “libmpich.a” library use of a function, gethostbyname, that requires Dynamic linking. You can use the flag “-Bstatic_pgi” to statically link the PGI run time libraries and dynamically link the system libraries. However, this will not solve your first error.

For the “File format not recognized” error, how was the “libmpichf90nc.a” library created? Was is the out put of the command “file /usr/local/mvapich/lib/libmpichf90nc.a”?

  • Mat

Thank you very much Mat and zenpharaohs

I use -Bstatic_pgi as Mat said instead. It works!!! However -ldl does not unfortunately.

Since I am not the admin, I dont know how this lib was created.
Is there any other way to know this info except asking the person who did that?

file command gives
/usr/local/mvapich/lib/libmpichf90nc.a: data

It is not archive. I guess this is the cause. How do I fix it? It seems asking admin to rebuild it is the only way

Mat, I am also wondering the difference between -O3 and -Bstatic if it does not cost much time to type. I mean why the latter would not cause this lib problem. Or maybe you can indicate where I can find the answers

Again thanks a lot.

Yisen

I made a try on another machine where I believe libmpichf90nc.a is right. But…new problem comes out

/usr/bin/ld: cannot find -lmtl_common

It seems libmtl_common was not found. Where is it?

Yisen

Hi Yisen,

It is not archive. I guess this is the cause. How do I fix it? It seems asking admin to rebuild it is the only way

Yes. In the mean time, you can try using the pre-built MPICH library that ships with the compilers using the flag “-Mmpi=mpich”. Though, this is an optional install so may or may not be available on your system.

Mat, I am also wondering the difference between -O3 and -Bstatic if it does not cost much time to type. I mean why the latter would not cause this lib problem.

“-O3” is a compiler optimization flag while “-Bstatic” is a linker flag which tells the linker to only use static libraries.

Or maybe you can indicate where I can find the answers

The PGI user’s guide is a good reference http://www.pgroup.com/doc/pgiug.pdf

/usr/bin/ld: cannot find -lmtl_common

This means that the linker can’t find this library. Most likely you just need to add the flag “-L/path/to/the/mtl/common/library/dir” to the link line (be sure to use the actual PATH to the library).

Hope this helps,
Mat

Hi Mat

Many thanks. I checked the libmtl_common.so. It is from InfiniBand package.
If I use Bstatic which may only link static lib, it will say missing libmtl_common.so.

My question is why it calls this lib during compiling? I believe my program is not InfiniBand-dependent. But how could this happen?

I know this is kind of beyond pgi but I 'd really appreciate it if you can help explain this!!

BTW, does the Bstatic_pgi require something like a certain version. One of the machine shows me “pgf90-Warning-Unknown switch: -Bstatic_pgi”

Yisen

Hi Yisen,

I checked the libmtl_common.so. It is from InfiniBand package.
If I use Bstatic which may only link static lib, it will say missing libmtl_common.so.

Makes sense. -Bstatic tells the linker to only use static (.a) libraries. libmtl_common.so is a Dynamic library (.so) so would be ignored.

My question is why it calls this lib during compiling? I believe my program is not InfiniBand-dependent. But how could this happen?

It’s not a library the PGI driver would add to your link. So either you’re using an Infinband MPI driver that’s adding the library for you, or it’s included as part of your link commands coming from a makefile or build script.

BTW, does the Bstatic_pgi require something like a certain version. One of the machine shows me “pgf90-Warning-Unknown switch: -Bstatic_pgi”

I’ve forgotten the exact version when this was added but I think it was around 7.0.

  • Mat

Hi Mat

I found the version. The version of pgi in both machines is 6.1. One can identify -Bstatic_pgi but the other not.

could it be any other reason?

Yisen

Hi Yisen,

I verified that the flag was added to version 6.2 so I suspect that one of the systems is not 6.1. Try running “pgf90 -help -Bstatic_pgi -V” to see the version.

  • Mat