Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

Fortran compiler with option -static and NetCDF library

$
0
0

Hello,

I have a difficulty to compile the Fortran code with option -static when the NetCDF library is required.  I explain the issue in detail as following.

We have two Red Hat Enterprise Linux 7.4 64-bit system machines.  Due to security consideration, one of the machines (called machine 1 later) is only installed OS.  The other machine (called machine 2) is installed Intel compiler and NetCDF library.  Now we want to compile our Fortran code on machine 2 to generate an executable file and run this executable file on machine 1.  In order to run it on machine 1, we need to use option -static on machine 2 to compile the Fortran code.

First I compiled a simple Fortran code (without using NetCDF library) with and without option -static on machine 2.  The generated executable files can be run on machine 1 to get the same results.  Next I can successfully compile a Fortran with using NetCDF library without option -static on machine 2.  The generated executable can be run on machine 2, but cannot be run on machine 1 because this executable file loads the Intel and NetCDF libraries which are not installed on machine 1.  When I compile the Fortran code with option -static on machine 2, the compilation fails and the error message are such as:

/usr/local/lib/libnetcdff.a(fort-attio.o): In function `nf_put_att_text_':
fort-attio.c:(.text+0x70): undefined reference to `nc_put_att_text'
/usr/local/lib/libnetcdff.a(fort-attio.o): In function `nf_get_att_text_':
fort-attio.c:(.text+0x175): undefined reference to `nc_get_att_text'
/usr/local/lib/libnetcdff.a(fort-attio.o): In function `nf_put_att_int1_':
fort-attio.c:(.text+0x287): undefined reference to `nc_put_att_schar'
/usr/local/lib/libnetcdff.a(fort-attio.o): In function `nf_get_att_int1_':
fort-attio.c:(.text+0x395): undefined reference to `nc_get_att_schar'
/usr/local/lib/libnetcdff.a(fort-attio.o): In function `nf_put_att_int2_':
fort-attio.c:(.text+0x4a7): undefined reference to `nc_put_att_short'
/usr/local/lib/libnetcdff.a(fort-attio.o): In function `nf_get_att_int2_':   and more

From these error messages, it is obviously that the NetCDF library is not imported when the option -static is used (note: if the option -static is not requested, the compilation goes through successfully).  

Have anyone in this forum come across the same issue and if yes, how to solve it?  Your comments are greatly appreciated.

Thanks,

Lianyuan

 


Viewing all articles
Browse latest Browse all 2746


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>