[netcdfgroup] netcdf-4.3.3.1 link problem with openmpi on Ubuntu (using mpicc)

Hi.
I'm trying to compile one of the ucar mpi example files for a class and
am having some elementary difficulty pointing to the netcdf libraries. I
haven't used the openmpi compiler (wrapper) before so I'm flailing a
bit. Any pointers would be most welcome.

hellyj@mae2:/data2/mpi-geospatial/src/c/ucar-examples$ make
mpicc -O1 -w  -I/usr/local/netcdf/include -L/usr/local/netcdf/lib 
-lnetcdf  simple_xy_wr.c -o simple_xy_wr
/tmp/cc0uYG2N.o: In function `main':
simple_xy_wr.c:(.text+0x44): undefined reference to `nc_create'
simple_xy_wr.c:(.text+0x4f): undefined reference to `nc_strerror'
simple_xy_wr.c:(.text+0x87): undefined reference to `nc_def_dim'
simple_xy_wr.c:(.text+0x92): undefined reference to `nc_strerror'
simple_xy_wr.c:(.text+0xca): undefined reference to `nc_def_dim'
simple_xy_wr.c:(.text+0xd5): undefined reference to `nc_strerror'
simple_xy_wr.c:(.text+0x127): undefined reference to `nc_def_var'
simple_xy_wr.c:(.text+0x132): undefined reference to `nc_strerror'
simple_xy_wr.c:(.text+0x15b): undefined reference to `nc_enddef'
simple_xy_wr.c:(.text+0x166): undefined reference to `nc_strerror'
simple_xy_wr.c:(.text+0x198): undefined reference to `nc_put_var_int'
simple_xy_wr.c:(.text+0x1a3): undefined reference to `nc_strerror'
simple_xy_wr.c:(.text+0x1cc): undefined reference to `nc_close'
simple_xy_wr.c:(.text+0x1d7): undefined reference to `nc_strerror'
collect2: error: ld returned 1 exit status
make: *** [simple_xy_wr] Error 1

Here's the makefile:

##############################################################################  
                                                              

# FILE:
Makefile.MPI.c                                                                  
                                                      

#
DESCRIPTION:                                                                    
                                                            

#   Makefile for all MPI C Language example
codes                                                                           
                  

# AUTHOR: J.
Helly                                                                           
                                                 

# LAST REVISED: 
08/16/15                                                                        
                                             

############################################################################### 
                                                              

LD_LIBRARY_PATH="/usr/local/netcdf/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
#                                                                               
                                                              

#Uncomment your choice of
compiler                                                                        
                                    

CC         = mpicc
CFLAGS     = -I/usr/local/netcdf/include
LIB_NETCDF = -L/usr/local/netcdf/lib
LDFLAGS    = ${LIB_NETCDF}

#Add your choice of
flags                                                                           
                                          

FLAGS   =   -O1 -w

all:    simple_xy_wr
clean:
        /bin/rm -rf     \
        *.o

simple_xy_wr:  simple_xy_wr.c
        $(CC) $(FLAGS) ${CFLAGS} ${LDFLAGS} -lnetcdf  simple_xy_wr.c -o
simple_xy_wr


Thanks.
J.

-- 
John Helly, University of California, San Diego / San Diego Supercomputer 
Center / Scripps Institution of Oceanography / 760 840 8660 mobile / stonesteps 
(Skype) / stonesteps7 (iChat) / http://www.sdsc.edu/~hellyj

begin:vcard
fn:John Helly
n:Helly;John
email;internet:hellyj@xxxxxxxx
tel;work:760 840 8660
tel;cell:760 840 8660
x-mozilla-html:FALSE
version:2.1
end:vcard

  • 2015 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: